简体   繁体   English

IIS7上托管的MVC2网站显示目录列表而不是Home / Index

[英]MVC2 Website hosted on IIS7 shows directory listing not the Home/Index

I am trying to host a MVC2 website to IIS. 我正在尝试将MVC2网站托管到IIS。 Steps I have followed: 我遵循的步骤:

  1. Create a Website in IIS ( define directory defined physical path and app pool) 在IIS中创建网站(定义目录定义的物理路径和应用程序池)
  2. Published code from visual studio to the physical path. 从Visual Studio发布代码到物理路径。

But when I tried to browse my site it was giving me error 但是,当我尝试浏览我的网站时,它给了我错误

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory. HTTP错误403.14-禁止Web服务器配置为不列出此目录的内容。

So, I enabled Directory Browsing feature, Now it only shows directory listing. 因此,我启用了目录浏览功能,现在它仅显示目录列表。 What I have tried? 我尝试了什么?

  1. Added wildcard script map for aspnet_isapi.dll 为aspnet_isapi.dll添加了通配符脚本映射
  2. enabled HTTP Redirection and some other things that I have found on some answers related to this question but nothing worked for me. 启用了HTTP重定向,以及我在与此问题相关的一些答案中发现的其他内容,但对我没有任何帮助。

My routing configurations are 我的路由配置是

   public class MvcApplication : System.Web.HttpApplication
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );


    }

    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        RegisterRoutes(RouteTable.Routes);
    }
}

Here are the things you might check: 您可以检查以下内容:

  1. If your application is using ASP.NET 4 ensure that this is registered in IIS. 如果您的应用程序使用的是ASP.NET 4,请确保已在IIS中进行了注册。 The following command should register it using the aspnet_regiis.exe tool: c:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_regiis - ir (adapt the paths with the proper version of the framework if necessary). 以下命令应使用aspnet_regiis.exe工具对其进行注册: c:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\aspnet_regiis - ir (如果需要,请使用适当版本的框架来调整路径)。
  2. Ensure that the application pool which is configured for the website is using Integrated pipeline mode. 确保为网站配置的应用程序池正在使用集成管道模式。

have you found a solution? 你找到解决办法了吗? I've been facing the same issue for hours. 我已经面对相同的问题几个小时了。 Here is my strange story. 这是我的奇怪故事。

I was configuring a fresh win srv 2008 R2 with IIS installed through role (7.5....) and Added the same components I have in my dev environment's IIS. 我正在配置一个全新的win srv 2008 R2,并通过角色(7.5 ....)安装了IIS,并添加了我在开发环境的IIS中具有的相同组件。 I thought that my system had got .net fw 4.0 because I've been able to crate asp.net 4.0 app pools, maybe because I had already had the 4.5 installed. 我以为我的系统拥有.net fw 4.0,因为我能够创建asp.net 4.0应用程序池,也许是因为我已经安装了4.5。 I had also checked the asp.net installed versions on IIS through aspnet_regiis.exe -lv and my ASP.NET v.4.0.... was magically there in both 32 and 64 bit versions. 我还通过aspnet_regiis.exe -lv和ASP.NET v.4.0 ....检查了IIS在asp.net上安装的版本。在32位和64位版本中,魔术都存在。

but... 但...

I noticed something strange watching at the Default Web Site structure: I had only the aspnet_client\\system_web\\2_0_50707 folder. 我注意到在“默认网站”结构中有一些奇怪的现象:我只有aspnet_client \\ system_web \\ 2_0_50707文件夹。 So the 4.0.... folder was missing. 因此缺少4.0 ...文件夹。

My solution. 我的解决方案。 I've uninstalled .net 4.5 from the server, then installed the v.4.0 downloading the package from microsoft. 我已经从服务器上卸载了.net 4.5,然后安装了v.4.0,并从Microsoft下载了该软件包。 Then I've registered my aspnet 4.0 version using the aspnet_regiis -i present in its folder (%windir%\\Microsoft.NET\\Framework64\\v4.0.30319). 然后,我使用其文件夹(%windir%\\ Microsoft.NET \\ Framework64 \\ v4.0.30319)中的aspnet_regiis -i注册了我的aspnet 4.0版本。

After reinstalling my mvc3/razor web app, everything worked fine, even without installing mvc3 components on the server. 重新安装我的mvc3 / razor Web应用程序后,即使没有在服务器上安装mvc3组件,一切都可以正常工作。

Morale, ensure that you have the fw version of your choice really installed in the system and configured in iis (aspnet). 士气,请确保已在系统中真正安装并在iis(aspnet)中配置了所选的固件版本。

Hope this helps. 希望这可以帮助。

Ciao. 再见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM