在monodevelop中使用@HtmlHelper的不便

本文关键字:@HtmlHelper monodevelop | 更新日期: 2023-09-27 18:19:21

我是开发monodevelop (linux)的新手。我正在创建一个MVC 5项目和Web。配置到视图文件夹有:

<system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing" />
      </namespaces>
    </pages>
</system.web.webPages.razor>

然而,在我的索引。cshtml @Html。ActionLink("NHibernate","Index")或任何组合(如@Html。ActionLink("NHibernate", "Index", "Home", new {area = "NH"}, new {@class = "btn btn-primary"}))抛出以下异常:

系统。MissingMethodException"RouteCollection方法。get_AppendTrailingSlash'未找到。

描述:HTTP 500。处理请求出错。详细信息:非web异常。异常起源(应用程序或对象的名称):System.Web.Mvc。异常堆栈跟踪:System.Web.Routing. getvirtualpathforareaRouteCollection路由,System. web . routing . requestContext字符串名称,System.Web.Routing.RouteValueDictionary值,System.Boolean&usingAreas) [0x00052] in:0System.Web.Routing. getvirtualpathforareaRouteCollection路由,System. web . routing . requestContext字符串名称,System.Web.Routing.RouteValueDictionary值)[0x00000] in:0System. web . mvc . urlhelper . generateurl字符串routeName,系统。String actionName, System。String controllerName, System.Web.Routing.RouteValueDictionary routeValues, System.Web.Routing.RouteCollection routeCollection, System.Web.Routing.RequestContext requestContext, Boolean includeImplicitMvcValues) [0x00035] in:0System. web . mvc . urlhelper . generateurl字符串routeName,系统。String actionName, System。String controllerName, System。字符串协议,系统。主机名,系统。字符串片段,System.Web.Routing.RouteValueDictionary routeValues, System.Web.Routing.RouteCollection routeCollection, System.Web.Routing.RequestContext requestContext, Boolean includeImplicitMvcValues) [0x00000] in:0System.Web.Routing. htmlhelper . generatelinkinternalrouteCollection, System. web . routing . routeCollection。字符串linkText, System。字符串routeName,系统。String actionName, System。String controllerName, System。字符串协议,系统。主机名,系统。字符串片段,System.Web.Routing.RouteValueDictionary routeValues, dictionary 2 htmlAttributes, Boolean includeImplicitMvcValues) [0x00000] in <filename unknown>:0 at System.Web.Mvc.HtmlHelper.GenerateLink (System.Web.Routing.RequestContext requestContext, System.Web.Routing.RouteCollection routeCollection, System.String linkText, System.String routeName, System.String actionName, System.String controllerName, System.String protocol, System.String hostName, System.String fragment, System.Web.Routing.RouteValueDictionary routeValues, IDictionary 2 htmlAttributes) [0x00000] in:0System.Web.Routing. htmlhelper . generatellinkrouteCollection, System. web . routing . routeCollection。字符串linkText, System。字符串routeName,系统。String actionName, System。String controllerName, System.Web.Routing.RouteValueDictionary routeValues, dictionary 2 htmlAttributes) [0x00000] in <filename unknown>:0 at System.Web.Mvc.Html.LinkExtensions.ActionLink (System.Web.Mvc.HtmlHelper htmlHelper, System.String linkText, System.String actionName, System.String controllerName, System.Web.Routing.RouteValueDictionary routeValues, IDictionary 2 htmlatattributes) [0x00029] in:0在系统。web . mvc . html .链接扩展。HtmlHelper, System。字符串linkText, System。String actionName) [0x0000e] in:0在ASP._Page_Views_Home_Index_cshtml。执行()[0x0010e] in/home/admin1/Proyectos/TestMVC/TestMVC/Views/Home/Index.cshtml:14at System.Web.WebPages.WebPageBase.ExecutePageHierarchy () [0x00054] in:0at System.Web.Mvc.WebViewPage.ExecutePageHierarchy () [0x0001d] in:0at System.Web.WebPages.StartPage.RunPage () [0x0000d] in:0at System.Web.WebPages.StartPage.ExecutePageHierarchy () [0x0001a] in:0执行页面层级(executepagehierarchy)WebPageContext pageContext, system . io . textwwriter, System.Web.WebPages.WebPageRenderingBase startPage) [0x00027] in:0view . renderview (view . renderview)ViewContext ViewContext, System. io . textwriter, System. io . textwriter。对象实例)[0x000c7] in:0在系统. web . mvc . buildmanagercompiledview . renderViewContext ViewContext, system . io . textwwriter writer) [0x00067] in:0view resultbase . executeresult (ControllerContext context) [0x00080] in:0System.Web.Mvc. controlleractioninvoker . invokeactionresultControllerContext ControllerContext, System.Web.Mvc.ActionResult actionResult) [0x00000] in:0at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (IList 1 filters, Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x0000b] in <filename unknown>:0 at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive (IList 1 filters, Int32 filterIndex, System.Web.Mvc.ResultExecutingContext preContext, System.Web.Mvc.ControllerContext, System.Web.Mvc.ActionResult actionResult) [0x0004f] in:0

在monodevelop中使用@HtmlHelper的不便

Monodevelop的实际框架版本不支持AppendTrailingSlash属性。目前最好的解决方案是使用标准的html。