【发布时间】:2020-02-24 04:26:14
【问题描述】:
通过传递模型返回视图时遇到问题。
errorMessage 无法将源类型 eCaptis.Models.Patient 绑定到模型类型 Umbraco.Core.Models.PublishedContent.IPublishedContent。
public class PatientController : SurfaceController
{
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Patient patient = db.Patients.Find(id);
if (patient == null)
{
return HttpNotFound();
}
return PartialView( patient);
}
}
我可能怀疑路由有问题,因为在安装 Umbraco v8 后,Debugger 没有点击 RouteConfig.cs
背景知识:我在 Umbraco 中创建了一个名为 home 的文档类型,它有一个子项编辑和登录
主页将显示一个表格,单击名称应该导航到编辑患者视图,因此我在单击患者姓名时将患者的 Id 传递给控制器,如上面的代码所示。
这样做我的 URL 将从 http://localhost:12345 更改为 http://localhost:12345/umbraco/Surface/Patient/Edit/345
一般来说,如果我们不使用表面控制器或 Umbraco,此 URL 可能类似于 http://localhost:12345 到 http://localhost:12345/Patient/Edit/345
我什至研究过路线劫持,但这对我没有帮助,或者可能是因为我缺乏了解。
非常感谢任何解决此问题的帮助。 提前致谢
【问题讨论】:
标签: asp.net-mvc view routing url-routing umbraco8