MVCContrib InputForm出现问题和 SparkViewEngine

发布于 2024-08-16 14:57:14 字数 664 浏览 3 评论 0原文

我正在尝试使用 MVCContrib InputBuilders 但遇到麻烦。我还使用 S#arp 架构和 Spark。我的 Spark 视图如下所示:

new.spark:

<viewdata model="NewUserViewModel" />
${Html.InputForm<NewUserViewModel>()}

我的 global.asax.cs 包含:

  protected void Application_Start() {
    XmlConfigurator.Configure();
    var controller = InitializeServiceLocator();
    ModelBinders.Binders.DefaultBinder = new SharpModelBinder();            
    ViewEngines.Engines.Clear();
    InputBuilder.BootStrap();
    ViewEngines.Engines.Add(controller.Resolve<IViewEngine>());
    RouteRegistrar.RegisterRoutesTo(RouteTable.Routes);
  }

I am trying to use MVCContrib InputBuilders but I am having trouble. I am also using S#arp architecture and spark. My spark view looks like this:

new.spark:

<viewdata model="NewUserViewModel" />
${Html.InputForm<NewUserViewModel>()}

My global.asax.cs contains:

  protected void Application_Start() {
    XmlConfigurator.Configure();
    var controller = InitializeServiceLocator();
    ModelBinders.Binders.DefaultBinder = new SharpModelBinder();            
    ViewEngines.Engines.Clear();
    InputBuilder.BootStrap();
    ViewEngines.Engines.Add(controller.Resolve<IViewEngine>());
    RouteRegistrar.RegisterRoutesTo(RouteTable.Routes);
  }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

韵柒 2024-08-23 14:57:14

当我回答自己的问题时,我讨厌它,但我发现将其添加到 下的 /Views/Web.config 解决了我的问题。

    <pages
    validateRequest="false"
    pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <controls>
            <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
        </controls>
    </pages>

我不太确定为什么这有帮助。我的猜测是我的应用程序被配置为仅使用 Spark 视图,这将添加常规视图引擎,但我不是这里的专家。

I hate it when I answer my own question but I found adding this to the /Views/Web.config under </system.web> fixed my problem.

    <pages
    validateRequest="false"
    pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <controls>
            <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
        </controls>
    </pages>

I'm not really sure why that helped. My guess is my app was configured to only to work with spark views and this is adding the regular view engine back in, but I am not expert here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文