asp.net-mvc 在 IIS7 上安装 MVC 网站

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10381016/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 01:54:58  来源:igfitidea点击:

Install MVC website on IIS7

asp.net-mvciis-7

提问by TamarG

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

我使用 VisualStudio 构建了一个 C#-MVC3 网站,效果很好。

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

我需要在另一台计算机上安装该网站以进行检查。电脑有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.

我尝试安装(我第一次......我真的不知道 IIS),当我浏览站点(localhost/mySite)时,我可以看到所有目录(控制器、视图......)但我不能查看网站本身。

I cansee 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)

可以看到一个特定的文件(如 localhost/mySite/Content/img.jpg),但我看不到带有控制器的站点(localhost/mySite 或 localhost/mySite/Home)

What to to?

要做什么?

回答by mikus

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

首先,安装ASP MVC,然后根据您的架构运行以下程序之一:

32bit (x86) Windows

32 位 (x86) 视窗

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

64bit (x64) Windows

64 位 (x64) 视窗

%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

还可以查看此线程以获取更多信息: IIS 7.5 上的 ASP.NET MVC

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

在这些步骤之后,您可能还需要重新创建您的应用程序/站点。

回答by kylebonallo

Extension to @mikus answer (Feb 2017)

@mikus 答案的扩展(2017 年 2 月)

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

我在本地机器上的ASP.NET MVC 4.5项目中遇到了上面描述的确切问题,该项目显示 IIS 403 错误。

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:

1)。在命令提示符窗口中按照上面 mikus 的回答(我使用 x64 版本)。我收到了一条带有“不受支持”消息的回复,但其中包含一个有用的链接:

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

...此版本的操作系统不支持此选项。管理员应改为使用“打开/关闭 Windows 功能”对话框、服务器管理器管理工具或 dism.exe 命令行工具安装/卸载带有 IIS8 的 ASP.NET 4.5。有关更多详细信息,请参阅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:

2)。使用 Microsoft 帮助页面链接中提供的分步说明:http: //go.microsoft.com/fwlink/?LinkID=216771我只需要执行第 7 步和第 8 步,我在下面详细介绍了这些步骤:

- 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)。您的 IIS 站点现在应该可以按预期工作了 - 对我来说确实如此。再次在浏览器中点击该站点进行测试。

回答by amaters

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

是否安装了MVC3?这是将 MVC 站点发布到另一台 PC 时最常见的原因

回答by Ajoy Hazra

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

如果您在 Global.asax.cs 中已经有 MVC 的默认设置,请将您的应用程序池托管管道模式更改为集成

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