ASP.NET MVC和IIS 5 [英] ASP.NET MVC and IIS 5
问题描述
什么是获得托管ASP.NET MVC应用程序中对IIS 5(6或7)工作的最佳途径。当我想发表我的ASP.NET MVC应用程序,所有我似乎得到的是404错误。我已经做了一些googleing,并已发现一对夫妇的解决方案,但也显得超级优雅,而且我担心,如果他们将无法使用,一旦我来使用共享主机环境的应用程序。
<一个href=\"http://blogs.microsoft.co.il/blogs/dorony/archive/2007/12/15/using-asp-net-mvc-on-iis-5.aspx\">Solution 1
- 右键点击您的inetmgr.exe应用程序虚拟目录。
- 属性 - >虚拟目录标签 - >配置。
- 添加新的映射扩展。扩展应该。*,这将是
映射到可执行
C:\\ WINDOWS \\ Microsoft.NET \\框架\\ V2.0.50727 \\ ASPNET_ISAPI.DLL,
或上的相应位置
计算机(你可以简单地复制此
从.aspx文件的映射)。上
映射取消选中检查文件
存在。
- 3×OK,你去好。
- 如果你愿意,你可以将此设置应用到所有网站。在
第一步,点击默认Web站点
节点,而不是你自己的虚拟
目录下,并在第2步进入
主目录选项卡。剩下的就是
一样的。
块引用>这似乎哈克路由一切通过ASP.NET一点点。
编辑MVC路由URL中包含.mvc然后按照围绕这个扩展在溶液1中的步骤。 编辑:原图像链接丢失了,但在这里,它是从谷歌的缓存:的
块引用>解决方案答案是这里
如果* .mvc扩展名未注册
到主机,它会给404
例外。托管的工作方式
在这种情况下,MVC的应用程式是修改
在Global.asax中的路由caluse
方法如下:
routes.Add(新
路线({}控制器.mvc.aspx / {}行动,
新MvcRouteHandler()){
默认值=新RouteValueDictionary(新{控制器
=YourController})});
在这样所有的控制器
请求将在* .mvc.aspx结束,
这是由您的主机的认可。
而作为MVC dll文件被复制到
当地的垃圾桶,没有什么特别的setttings
需要将它做。
块引用>What is the best way to get hosting of an ASP.NET MVC application to work on IIS 5 (6 or 7). When I tried to publish my ASP.NET MVC application, all I seemed to get is 404 errors. I've done a bit of googleing and have found a couple of solutions, but neither seem super elegant, and I worry if they will be unusable once I come to use a shared hosting environment for the application.
- 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.
It seems a tad hacky to route everything through ASP.NET.
Edit the MVC routing to contain .mvc in the URL and then follow the steps in solution 1 based around this extension. Edit: The original image link was lost, but here it is from Google's Cache:
解决方案Answer is 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.
这篇关于ASP.NET MVC和IIS 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!