加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-15 18:53:43 所属栏目:asp.Net 来源:网络整理
导读:什么是获得托管ASP.NET MVC应用程序在IIS 5(6或7)上工作的最佳方式。当我试图发布我的ASP.NET MVC应用程序,我似乎得到的是404错误。我做了一些googleing,找到了几个解决方案,但似乎并不优雅,我担心如果他们将无法使用一旦我使用共享托管环境的应用程序。
什么是获得托管ASP.NET MVC应用程序在IIS 5(6或7)上工作的最佳方式。当我试图发布我的ASP.NET MVC应用程序,我似乎得到的是404错误。我做了一些googleing,找到了几个解决方案,但似乎并不优雅,我担心如果他们将无法使用一旦我使用共享托管环境的应用程序。

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:WINDOWSMicrosoft.NETFrameworkv2.0.50727aspnet_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中的步骤。修改:原始图片链接已丢失,但此处是来自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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读