单ASP.NET MVC波浪中的href导致System.NotImplementedException [英] Mono ASP.NET MVC tilde in href causes System.NotImplementedException

查看:336
本文介绍了单ASP.NET MVC波浪中的href导致System.NotImplementedException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让在Ubuntu 14.04.1使用单声道3.12.0一个ASP.NET应用程序。每当我尝试使用了波浪线的HREF在我的 _Layout.cshtml ,我收到了 System.NotImplementedException

我与MonoDevelop的3种不同的ASP.NET MVC剃刀解决方案,每个人都有同样的问题。

我的 _Layout.cshtml 文件看起来是这样的:

 <!DOCTYPE HTML>
< HTML和GT;
< HEAD>
    <标题> @ ViewBag.Title< /标题>
    <链接HREF =〜/ CSS / normalize.css的rel =stylesheet属性类型=文/ CSS/>
    <链接HREF =〜/ CSS / screen.css媒体=屏幕投影的rel =stylesheet属性类型=文/ CSS/>
    <链接HREF =〜/ CSS / print.css媒体=打印的rel =stylesheet属性类型=文/ CSS/>
    <! - [如果IE>
        <链接HREF =〜/ CSS / ie.css媒体=屏幕投影的rel =stylesheet属性类型=文/ CSS/>
    百分比抑制率ENDIF] - GT!;
< /头>
<身体GT;
    @RenderBody()
< /身体GT;
< / 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
请求的功能未实现。说明:HTTP 500.Error处理请求。联系方式:非网上例外。异常原点(应用程序或对象的名称):System.Web程序。异常堆栈跟踪:
在System.Web.HttpContextWrapper.GetService(的System.Type的serviceType)[0x00000]上述<文件名未知>:0
在System.Web.WebPages.UrlRewriterHelper.IsUrlRewriterTurnedOn(System.Web.HttpContextBase HttpContext的)[0x00000]上述<文件名未知>:0
在System.Web.WebPages.UrlRewriterHelper.WasRequestRewritten(System.Web.HttpContextBase HttpContext的)[0x00000]上述<文件名未知>:0
在System.Web.WebPages.UrlUtil.GenerateClientUrlInternal(System.Web.HttpContextBase HttpContext的,System.String的contentPath)[0x00000]上述<文件名未知>:0
在System.Web.WebPages.UrlUtil.GenerateClientUrlInternal(System.Web.HttpContextBase HttpContext的,System.String的contentPath)[0x00000]上述<文件名未知>:0
在System.Web.WebPages.UrlUtil.GenerateClientUrl(System.Web.HttpContextBase HttpContext的,System.String基本路径,路径System.String,System.Object的[] pathParts)[0x00000]上述<文件名不明>:0
在System.Web.WebPages.WebPageExecutingBase.Href(System.String路径,System.Object的[] pathParts)[0x00000]上述<文件名不明>:0
在ASP._Page_Views_Shared__Layout_cshtml.Execute()[0x00000]上述<文件名未知>:0
在System.Web.WebPages.WebPageBase.ExecutePageHierarchy()[0x00000]上述<文件名未知>:0
在System.Web.Mvc.WebViewPage.ExecutePageHierarchy()[0x00000]上述<文件名未知>:0
在System.Web.WebPages.WebPageBase.ExecutePageHierarchy(System.Web.WebPages.WebPageContext的pageContext,System.IO.TextWriter作家,System.Web.WebPages.WebPageRenderingBase起始页)[0x00000]上述<文件名不明>:0
在System.Web.WebPages.WebPageBase.ExecutePageHierarchy(System.Web.WebPages.WebPageContext的pageContext,System.IO.TextWriter作家)[0x00000]上述<文件名不明>:0
在System.Web.WebPages.WebPageBase +下; [0x00000]上述&lt b__6(System.IO.TextWriter作家);文件名未知>> c__DisplayClass7&下; RenderPageCore&GT:0
在System.Web.WebPages.HelperResult.WriteTo(System.IO.TextWriter作家)[0x00000]上述<文件名不明>:0
在System.Web.WebPages.WebPageExecutingBase.WriteTo(System.IO.TextWriter作家,System.Web.WebPages.HelperResult内容)[0x00000]上述<文件名不明>:0
在System.Web.WebPages.WebPageBase.Write(System.Web.WebPages.HelperResult结果)[0x00000]上述<文件名不明>:0
在System.Web.WebPages.WebPageBase.RenderSurrounding(System.String partialViewName,System.Action`1体)[0x00000]上述<文件名未知>:0
在System.Web.WebPages.WebPageBase.PopContext()[0x00000]上述<文件名未知>:0
在System.Web.WebPages.WebPageBase.ExecutePageHierarchy(System.Web.WebPages.WebPageContext的pageContext,System.IO.TextWriter作家,System.Web.WebPages.WebPageRenderingBase起始页)[0x00000]上述<文件名不明>:0
在System.Web.Mvc.RazorView.RenderView(System.Web.Mvc.ViewContext viewContext,System.IO.TextWriter作家,比如System.Object的)[0x00000]上述<文件名不明>:0
在System.Web.Mvc.BuildManagerCompiledView.Render(System.Web.Mvc.ViewContext viewContext,System.IO.TextWriter作家)[0x00000]上述<文件名不明>:0
在System.Web.Mvc.ViewResultBase.ExecuteResult(System.Web.Mvc.ControllerContext上下文)[0x00000]上述<文件名未知>:0
在System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(System.Web.Mvc.ControllerContext controllerContext,System.Web.Mvc.ActionResult的ActionResult)[0x00000]上述<文件名未知>:0
在System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1过滤器,的Int32 filterIndex,System.Web.Mvc.ResultExecutingContext preContext,System.Web.Mvc.ControllerContext controllerContext,System.Web.Mvc.ActionResult的ActionResult) 0x00000]上述<文件名未知>:0
在System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1过滤器,的Int32 filterIndex,System.Web.Mvc.ResultExecutingContext preContext,System.Web.Mvc.ControllerContext controllerContext,System.Web.Mvc.ActionResult的ActionResult) 0x00000]上述<文件名未知>:0版本信息:3.12.0(压缩包周六2月7日19点12分57秒UTC 2015年); ASP.NET版本:4.0.30319.17020


解决方案

有<一个href=\"https://github.com/mono/mono/commit/d35449e99bc1315657ec41de2c90661bb82fc66a#diff-4324c426d53ff23491eee60ac13c3c6e\"相对=nofollow>这个承诺在GitHub上它说,它增加了失位,支持MVC 5.2。提交被投入在2014年10

以上承诺表明,这是造成错误的功能进行了更新,像这样:


公众覆盖对象GetService的(类型的serviceType)
{
    <击>抛出新NotImplementedException();
    返回((的IServiceProvider)W).GetService(的serviceType);
}

根据您的文章,你正在运行的版本3.12。如果我看<一个href=\"https://github.com/mono/mono/blob/mono-3.12.0.76/mcs/class/System.Web.Abstractions/System.Web/HttpContextWrapper.cs\"相对=nofollow>最新版本3.12 ,提交现在还没有:


公众覆盖对象GetService的(类型的serviceType)
{
    抛出新NotImplementedException();
}

看样子你将不得不要么自己编译的最新版本,或者等到下单的释放。

另外一个(未经测试)的解决方法,因为在您的文章中的链接,是不使用波浪号:

 &LT;链接HREF =/ CSS / normalize.css的rel =stylesheet属性类型=文/ CSS/&GT;

I am trying to make an ASP.NET app using Mono 3.12.0 on Ubuntu 14.04.1. Whenever I try to use tildes in the hrefs in my _Layout.cshtml, I get a System.NotImplementedException.

I have made 3 different ASP.NET MVC Razor solutions with MonoDevelop and each one has the same problem.

My _Layout.cshtml file looks like this:

<!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>

I have also tried doing Url.Content("~/css/file.css") with the same error message.

Anybody know what's going on?

UPDATE

  • System.Web.Razor is version 3.0.0.0
  • System.Web.Mvc is version 5.2.0.0
  • System.Core is version 4.0.0.0

UPDATE 2

The complete error is:

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

解决方案

There is this commit on GitHub which says that it adds the missing bits to support MVC 5.2. The commit was put in on October 2014.

The above commit shows that the function that was causing the error was updated, like so:

public override object GetService (Type serviceType) 
{ 
    throw new NotImplementedException ();
    return ((IServiceProvider)w).GetService (serviceType); 
} 

According to your post you are running version 3.12. If I look at the latest 3.12 version, the commit is not there yet:

public override object GetService (Type serviceType) 
{ 
    throw new NotImplementedException (); 
}

It appears you will have to either compile the latest version yourself, or wait until the next Mono release.

One other (untested) workaround, given the links in your post, is to not use the tilde:

<link href="/css/normalize.css" rel="stylesheet" type="text/css" />

这篇关于单ASP.NET MVC波浪中的href导致System.NotImplementedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆