什么是获得托管ASP.NET MVC应用程序在IIS 5(6或7)上工作的最佳方式。当我试图发布我的ASP.NET MVC应用程序,我似乎得到的是404错误。我做了一些googleing,找到了几个解决方案,但似乎并不优雅,我担心如果他们将无法使用一旦我使用共享托管环境的应用程序。
- Right-click your application virtual directory on inetmgr.exe.
- Properties->Virtual Directory Tab-> Configuration.
- Add a new mapping extension. The extension should be .*,which will be
mapped to the Executable
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,
or the appropriate location on your
computer (you can simply copy this
from the mapping for .aspx files). On
the mapping uncheck “check that file
exists”.- 3 X OK and you’re good to go.
- If you want,you can apply this setting to all your web sites. In
step1,click on the “Default Web Site”
node instead of your own virtual
directory,and in step 2 go to the
“Home Directory” tab. The rest is the
same.
看起来有点黑客通过ASP.NET路由一切。
编辑MVC路由以在URL中包含.mvc,然后按照基于此扩展的解决方案1中的步骤。修改:原始图片链接已丢失,但此处是来自Google的缓存:
解决方法
答案是
here
If *.mvc extension is not registered
to the hosting,it will give 404
exception. The working way of hosting
MVC apps in that case is to modify
global.asax routing caluse in the
following way.routes.Add(new
Route(“{controller}.mvc.aspx/{action}”,
new MvcRouteHandler()) {
Defaults = new RouteValueDictionary (new{ controller
= “YourController”} ) });In this way all your controller request will end up in *.mvc.aspx,which is recognized by your hosting. And as the MVC dlls are copied into your local bin,no special setttings need to be done for it.