Mono ASP.NET href 中的 MVC 波浪号导致 System.NotImplementedException
Mono ASP.NET MVC tilde in href causes System.NotImplementedException
我正在尝试在 Ubuntu 14.04.1 上使用 Mono 3.12.0 制作一个 ASP.NET 应用程序。每当我尝试在 _Layout.cshtml
的 href 中使用波浪号时,我都会得到 System.NotImplementedException
.
我用 MonoDevelop 制作了 3 个不同的 ASP.NET MVC Razor 解决方案,每个都有相同的问题。
我的 _Layout.cshtml
文件如下所示:
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<link href="~/css/normalize.css" rel="stylesheet" type="text/css" />
<link href="~/css/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />
<link href="~/css/print.css" media="print" rel="stylesheet" type="text/css" />
<!--[if IE]>
<link href="~/css/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
<![endif]-->
</head>
<body>
@RenderBody()
</body>
</html>
我也尝试过 Url.Content("~/css/file.css")
并出现相同的错误消息。
有人知道发生了什么事吗?
更新
System.Web.Razor
是版本 3.0.0.0
System.Web.Mvc
是版本 5.2.0.0
System.Core
是版本 4.0.0.0
更新 2
完整的错误是:
System.NotImplementedException
The requested feature is not implemented.
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.
Exception stack trace:
at System.Web.HttpContextWrapper.GetService (System.Type serviceType) [0x00000] in <filename unknown>:0
at System.Web.WebPages.UrlRewriterHelper.IsUrlRewriterTurnedOn (System.Web.HttpContextBase httpContext) [0x00000] in <filename unknown>:0
at System.Web.WebPages.UrlRewriterHelper.WasRequestRewritten (System.Web.HttpContextBase httpContext) [0x00000] in <filename unknown>:0
at System.Web.WebPages.UrlUtil.GenerateClientUrlInternal (System.Web.HttpContextBase httpContext, System.String contentPath) [0x00000] in <filename unknown>:0
at System.Web.WebPages.UrlUtil.GenerateClientUrlInternal (System.Web.HttpContextBase httpContext, System.String contentPath) [0x00000] in <filename unknown>:0
at System.Web.WebPages.UrlUtil.GenerateClientUrl (System.Web.HttpContextBase httpContext, System.String basePath, System.String path, System.Object[] pathParts) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageExecutingBase.Href (System.String path, System.Object[] pathParts) [0x00000] in <filename unknown>:0
at ASP._Page_Views_Shared__Layout_cshtml.Execute () [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy () [0x00000] in <filename unknown>:0
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy () [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy (System.Web.WebPages.WebPageContext pageContext, System.IO.TextWriter writer, System.Web.WebPages.WebPageRenderingBase startPage) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy (System.Web.WebPages.WebPageContext pageContext, System.IO.TextWriter writer) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase+<>c__DisplayClass7.<RenderPageCore>b__6 (System.IO.TextWriter writer) [0x00000] in <filename unknown>:0
at System.Web.WebPages.HelperResult.WriteTo (System.IO.TextWriter writer) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageExecutingBase.WriteTo (System.IO.TextWriter writer, System.Web.WebPages.HelperResult content) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.Write (System.Web.WebPages.HelperResult result) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.RenderSurrounding (System.String partialViewName, System.Action`1 body) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.PopContext () [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy (System.Web.WebPages.WebPageContext pageContext, System.IO.TextWriter writer, System.Web.WebPages.WebPageRenderingBase startPage) [0x00000] in <filename unknown>:0
at System.Web.Mvc.RazorView.RenderView (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer, System.Object instance) [0x00000] in <filename unknown>:0
at System.Web.Mvc.BuildManagerCompiledView.Render (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer) [0x00000] in <filename unknown>:0
at System.Web.Mvc.ViewResultBase.ExecuteResult (System.Web.Mvc.ControllerContext context) [0x00000] in <filename unknown>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x00000] in <filename unknown>:0
at 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) [0x00000] in <filename unknown>:0
at 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) [0x00000] in <filename unknown>:0
Version Information: 3.12.0 (tarball Sat Feb 7 19:12:57 UTC 2015); ASP.NET Version: 4.0.30319.17020
this commit on GitHub 表示它添加了缺失的位以支持 MVC 5.2。该提交于 2014 年 10 月提交。
上面的提交显示导致错误的函数已更新,如下所示:
public override object GetService (Type serviceType)
{
throw new NotImplementedException ();
return ((IServiceProvider)w).GetService (serviceType);
}
根据您的 post,您的版本是 运行 3.12。如果我查看 the latest 3.12 version,还没有提交:
public override object GetService (Type serviceType)
{
throw new NotImplementedException ();
}
看来您要么自己编译最新版本,要么等到下一个 Mono 版本发布。
另一种(未经测试的)解决方法,根据您 post 中的链接,不使用波浪号:
<link href="/css/normalize.css" rel="stylesheet" type="text/css" />
我正在尝试在 Ubuntu 14.04.1 上使用 Mono 3.12.0 制作一个 ASP.NET 应用程序。每当我尝试在 _Layout.cshtml
的 href 中使用波浪号时,我都会得到 System.NotImplementedException
.
我用 MonoDevelop 制作了 3 个不同的 ASP.NET MVC Razor 解决方案,每个都有相同的问题。
我的 _Layout.cshtml
文件如下所示:
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<link href="~/css/normalize.css" rel="stylesheet" type="text/css" />
<link href="~/css/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />
<link href="~/css/print.css" media="print" rel="stylesheet" type="text/css" />
<!--[if IE]>
<link href="~/css/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
<![endif]-->
</head>
<body>
@RenderBody()
</body>
</html>
我也尝试过 Url.Content("~/css/file.css")
并出现相同的错误消息。
有人知道发生了什么事吗?
更新
System.Web.Razor
是版本3.0.0.0
System.Web.Mvc
是版本5.2.0.0
System.Core
是版本4.0.0.0
更新 2
完整的错误是:
System.NotImplementedException
The requested feature is not implemented.
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.
Exception stack trace:
at System.Web.HttpContextWrapper.GetService (System.Type serviceType) [0x00000] in <filename unknown>:0
at System.Web.WebPages.UrlRewriterHelper.IsUrlRewriterTurnedOn (System.Web.HttpContextBase httpContext) [0x00000] in <filename unknown>:0
at System.Web.WebPages.UrlRewriterHelper.WasRequestRewritten (System.Web.HttpContextBase httpContext) [0x00000] in <filename unknown>:0
at System.Web.WebPages.UrlUtil.GenerateClientUrlInternal (System.Web.HttpContextBase httpContext, System.String contentPath) [0x00000] in <filename unknown>:0
at System.Web.WebPages.UrlUtil.GenerateClientUrlInternal (System.Web.HttpContextBase httpContext, System.String contentPath) [0x00000] in <filename unknown>:0
at System.Web.WebPages.UrlUtil.GenerateClientUrl (System.Web.HttpContextBase httpContext, System.String basePath, System.String path, System.Object[] pathParts) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageExecutingBase.Href (System.String path, System.Object[] pathParts) [0x00000] in <filename unknown>:0
at ASP._Page_Views_Shared__Layout_cshtml.Execute () [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy () [0x00000] in <filename unknown>:0
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy () [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy (System.Web.WebPages.WebPageContext pageContext, System.IO.TextWriter writer, System.Web.WebPages.WebPageRenderingBase startPage) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy (System.Web.WebPages.WebPageContext pageContext, System.IO.TextWriter writer) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase+<>c__DisplayClass7.<RenderPageCore>b__6 (System.IO.TextWriter writer) [0x00000] in <filename unknown>:0
at System.Web.WebPages.HelperResult.WriteTo (System.IO.TextWriter writer) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageExecutingBase.WriteTo (System.IO.TextWriter writer, System.Web.WebPages.HelperResult content) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.Write (System.Web.WebPages.HelperResult result) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.RenderSurrounding (System.String partialViewName, System.Action`1 body) [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.PopContext () [0x00000] in <filename unknown>:0
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy (System.Web.WebPages.WebPageContext pageContext, System.IO.TextWriter writer, System.Web.WebPages.WebPageRenderingBase startPage) [0x00000] in <filename unknown>:0
at System.Web.Mvc.RazorView.RenderView (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer, System.Object instance) [0x00000] in <filename unknown>:0
at System.Web.Mvc.BuildManagerCompiledView.Render (System.Web.Mvc.ViewContext viewContext, System.IO.TextWriter writer) [0x00000] in <filename unknown>:0
at System.Web.Mvc.ViewResultBase.ExecuteResult (System.Web.Mvc.ControllerContext context) [0x00000] in <filename unknown>:0
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionResult actionResult) [0x00000] in <filename unknown>:0
at 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) [0x00000] in <filename unknown>:0
at 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) [0x00000] in <filename unknown>:0
Version Information: 3.12.0 (tarball Sat Feb 7 19:12:57 UTC 2015); ASP.NET Version: 4.0.30319.17020
this commit on GitHub 表示它添加了缺失的位以支持 MVC 5.2。该提交于 2014 年 10 月提交。
上面的提交显示导致错误的函数已更新,如下所示:
public override object GetService (Type serviceType) {throw new NotImplementedException ();return ((IServiceProvider)w).GetService (serviceType); }
根据您的 post,您的版本是 运行 3.12。如果我查看 the latest 3.12 version,还没有提交:
public override object GetService (Type serviceType) { throw new NotImplementedException (); }
看来您要么自己编译最新版本,要么等到下一个 Mono 版本发布。
另一种(未经测试的)解决方法,根据您 post 中的链接,不使用波浪号:
<link href="/css/normalize.css" rel="stylesheet" type="text/css" />