MVC5 routing error (404.0) error on IIS 7.5

落爺英雄遲暮 提交于 2020-02-03 18:50:11

问题


An old story of everything works fine on the development machine but not on the host server.

HTTP Error 404.0 - Not Found

  • Module IIS Web Core
  • Notification MapRequestHandler
  • Handler StaticFile
  • Error Code 0x80070002

Trying to produce the same error on the development machine by adding <remove name="UrlRoutingModule-4.0" /> to system.webServer - modules and resolving it when adding <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />, but that not works on the host. I've also try <modules runAllManagedModulesForAllRequests="true" /> but nothing changed.

And here is the handlers part:

<handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <remove name="WebDAV" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
      <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>

Few more information:

  • MVC.Net 5.2.2.0
  • IIS 7.5 on Windows 2008
  • Integrated .Net 4.0 application pool.

Is there anything else that I should do?

Now, having the same problem in IIS8, any idea?


回答1:


I had similar problem. It turns out to be discrepancy with Virtual folder name and the URL I was constructing to call Web API route:

var URLGetUserAccesses = "/api/Login/GetUserAccesses";

Vs.

var URLGetUserAccesses = "../api/Login/GetUserAccesses";


来源:https://stackoverflow.com/questions/27303523/mvc5-routing-error-404-0-error-on-iis-7-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!