gpt4 book ai didi

asp.net-mvc - ASP.NET MVC 和 IIS 5

转载 作者:行者123 更新时间:2023-12-03 10:42:02 25 4
gpt4 key购买 nike

什么是托管 ASP.NET MVC 应用程序以在 IIS 5(6 或 7)上运行的最佳方法。当我尝试发布我的 ASP.NET MVC 应用程序时,我似乎得到的只是 404 错误。我已经做了一些谷歌搜索并找到了一些解决方案,但似乎都不是 super 优雅,我担心一旦我开始为应用程序使用共享托管环境它们是否会无法使用。

Solution 1

  1. Right-click your application virtual directory on inetmgr.exe.
  2. Properties->Virtual Directory Tab-> Configuration.
  3. 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".
  4. 3 X OK and you're good to go.
  5. 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 路由所有内容似乎有点麻烦。

Solutions 2

编辑 MVC 路由以在 URL 中包含 .mvc,然后按照基于此扩展的解决方案 1 中的步骤进行操作。编辑:原始图像链接丢失了,但它来自谷歌的缓存:

alt text

最佳答案

答案是 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 - ASP.NET MVC 和 IIS 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57712/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com