Install MVC website on IIS7

时光怂恿深爱的人放手 提交于 2020-01-12 18:48:06

问题


I use VisualStudio to build a C#-MVC3 Website and it works great.

I need to install the website on a different computer to check it. The computer has IIS7.

I tried to install (my first time... I don't really know IIS), and when I browse the site (localhost/mySite) I can see all the directories (controllers, views...) but I can't see the site itself.

I can see a specific file (like localhost/mySite/Content/img.jpg) but I can't see the site with the controllers (localhost/mySite, or localhost/mySite/Home)

What to to?


回答1:


First, install ASP MVC, then run one of the following depending on your architecture:

32bit (x86) Windows

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir

64bit (x64) Windows

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir

also check this thread for more info: ASP.NET MVC on IIS 7.5

You could also need to recreate your application/site after these steps.




回答2:


Extension to @mikus answer (Feb 2017)

I had the exact problem described above with an ASP.NET MVC 4.5 project on my local machine which was showing IIS 403 errors.

The fix which may be of use to others:

1). Follow mikus's answer above (I used the x64 version) in a Command Prompt window. I received a response with an 'unsupported' message, but contained a useful link:

...This option is not supported on this version of the operating system. Administrators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Windows Features On/Off" dialog, the Server Manager management tool, or the dism.exe command line tool. For more details please see http://go.microsoft.com/fwlink/?LinkID=216771..."

2). Using the step-by-step instructions given in the link to the Microsoft help page: http://go.microsoft.com/fwlink/?LinkID=216771. I only had to do steps 7 and 8, which I have detailed below:

- Open 'Turn Windows features on or off' [Windows key then type 'Turn Windows features on or off' and open]
- Scroll down the list and expand 'Internet Information Services'
- Within that expand 'World Wide Web Services'
- Within that expand 'Application Development Features'
- Make sure 'ASP.NET 4.6' (or 3.5 if you require that) is ticked - mine was not.
- Save and close.

3). Your IIS site should now work as expected - it did for me. Hit the site in the browser again to test.




回答3:


Is MVC3 installed? It is the most common cause when publishing MVC sites to another PC




回答4:


Change your App Pool Managed Pipeline Mode to Integrated if you already have default settings for MVC in Global.asax.cs like

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 });
}


来源:https://stackoverflow.com/questions/10381016/install-mvc-website-on-iis7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!