【问题标题】:Umbraco Routing or Model bindingUmbraco 路由或模型绑定
【发布时间】: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:12345http://localhost:12345/Patient/Edit/345

我什至研究过路线劫持,但这对我没有帮助,或者可能是因为我缺乏了解。

非常感谢任何解决此问题的帮助。 提前致谢

【问题讨论】:

    标签: asp.net-mvc view routing url-routing umbraco8


    【解决方案1】:

    Umbraco 要求 SurfaceController 名称附加“SurfaceController”才能正常工作:https://umbraco.tv/videos/umbraco-v7/developer/fundamentals/surface-controllers/the-surface-controller/documentation

    所以希望它就像将控制器重命名为 PatientSurfaceController 一样简单?

    【讨论】:

      猜你喜欢
      • 2019-09-05
      • 2019-01-10
      • 2016-06-04
      • 1970-01-01
      • 2021-05-24
      • 2017-06-22
      • 2019-09-14
      • 1970-01-01
      • 2015-08-28
      相关资源
      最近更新 更多