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

3

6

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);
    }
}
Prevost answered 18/1, 2014 at 12:4 Comment(1)
Yes It is Integrated and I have tried these solutions but nothing worked for mePrevost
P
4

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.
Positive answered 21/1, 2014 at 13:7 Comment(10)
Application pool is integrated and I have tried the above tool but didn't worked for mePrevost
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?Positive
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.Prevost
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 workPrevost
If you put a simple .aspx page at the root is it served?Positive
Is your MVC2 application configured to serve extensionless routes? How does your routing configuration look like?Positive
Updated question with my routing configurations.Prevost
What if you try to access directly some controller action: http://example.com/home/index?Positive
let us continue this discussion in chatPrevost
"c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -ir" worked for me.Gateshead
W
0

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. 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. 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.

but...

I noticed something strange watching at the Default Web Site structure: I had only the aspnet_client\system_web\2_0_50707 folder. So the 4.0.... folder was missing.

My solution. I've uninstalled .net 4.5 from the server, then installed the v.4.0 downloading the package from 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).

After reinstalling my mvc3/razor web app, everything worked fine, even without installing mvc3 components on the server.

Morale, ensure that you have the fw version of your choice really installed in the system and configured in iis (aspnet).

Hope this helps.

Ciao.

Weatherboard answered 24/1, 2014 at 15:51 Comment(1)
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.Prevost
A
0

install mvc application with this command

install-windowsfeature web-asp-net45

or install ASP.Net 4 in role server in server managment Detail

Azoth answered 27/3, 2023 at 8:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.