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

10,072

Here are the things you might check:

  1. If your application is using ASP.NET 4 ensure that this is registered in 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).
  2. Ensure that the application pool which is configured for the website is using Integrated pipeline mode.
Share:
10,072
Rajesh Dhiman
Author by

Rajesh Dhiman

Hi, My name is Rajesh Dhiman. I am a full-stack web developer who is passionate about designing and implementing scalable and maintainable web applications/services with the TDD/BDD approach. I can develop complex server-side logic, definition, and maintenance of the central database, ensuring high performance and responsiveness to requests from the front-end. I have always been fascinated by finding out how things work and creating something new. I thrive when I can solve complex problems with elegant solutions using web technologies and even better - learn something on the way. In addition to my technical work, I am also passionate about mentoring people who want to start their carrier in software development. When I'm not coding, you can find me cycling or cooking something in my kitchen.

Updated on July 29, 2022

Comments

  • Rajesh Dhiman
    Rajesh Dhiman almost 2 years

    I am trying to host a MVC2 website to IIS. Steps I have followed:

    1. Create a Website in IIS ( define directory defined physical path and app pool)
    2. Published code from visual studio to the physical path.

    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.

    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
    2. enabled HTTP Redirection and some other things that I have found on some answers related to this question but nothing worked for me.

    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);
        }
    }
    
  • Rajesh Dhiman
    Rajesh Dhiman over 10 years
    Application pool is integrated and I have tried the above tool but didn't worked for me
  • Darin Dimitrov
    Darin Dimitrov over 10 years
    Is the application pool configured to run with .NET 4.0? Also have you verified that the application files are deployed to the correct directory to which the website is pointing?
  • Rajesh Dhiman
    Rajesh Dhiman over 10 years
    Yes the application pool is configured to .NET 4.0. and the directory to which website is pointing is like "C:\inetpub\wwwroot\myWeb" and this contains my published code.
  • Rajesh Dhiman
    Rajesh Dhiman over 10 years
    I don't know I have been stuck in this issue for quite some days and almost tried every solution found on internet but still not able to make it work
  • Darin Dimitrov
    Darin Dimitrov over 10 years
    If you put a simple .aspx page at the root is it served?
  • Darin Dimitrov
    Darin Dimitrov over 10 years
    Is your MVC2 application configured to serve extensionless routes? How does your routing configuration look like?
  • Rajesh Dhiman
    Rajesh Dhiman over 10 years
    Updated question with my routing configurations.
  • Darin Dimitrov
    Darin Dimitrov over 10 years
    What if you try to access directly some controller action: http://example.com/home/index?
  • Rajesh Dhiman
    Rajesh Dhiman over 10 years
  • Rajesh Dhiman
    Rajesh Dhiman over 10 years
    Thanks @edtruant, but my framework folder displays folders of all versions of .NET from v1.0.3705 to v4.0.30319. but I will try reinstalling and registering .NET framework.
  • endo64
    endo64 over 7 years
    "c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regi‌​is -ir" worked for me.