简体   繁体   English

如何将MVC3 Hello World应用程序部署到localhost并配置IIS

[英]How do I deploy MVC3 Hello World App to localhost and configure IIS

I am having some trouble deploying my MVC3 application to my localhost. 我在将我的MVC3应用程序部署到localhost时遇到了一些麻烦。 I am looking for details to build and deploy a ASP MVC 3 application to my local system. 我正在寻找构建和部署ASP MVC 3应用程序到我的本地系统的细节。 I've tried to deploy this, but have run into problem after problem. 我试图部署这个,但问题后遇到了问题。 Instead of tracking each problem down separately (and I may have to do this anyways) I would like to create a one stop guide for myself and others that see this post. 而不是单独跟踪每个问题(我可能不得不这样做)我想为自己和其他人看到这篇文章创建一站式指南。

I'm looking for steps including libraries to install (ASP MVC3, IIS, etc) on a Win7 SP1 machine with VS2010 installed. 我正在寻找安装VS2010的Win7 SP1机器上安装库(ASP MVC3,IIS等)的步骤。 Also how do I set up IIS, and how do I publish? 另外我如何设置IIS,以及如何发布? The goal will be to deploy this web app to another Win7 machine in the house, but localhost will be the first step. 目标是将这个Web应用程序部署到家中的另一台Win7机器上,但localhost将是第一步。 In addition, it would be helpful to know whatever steps are necessary to make the website accessible from another machine on the same network. 此外,了解使网站可以从同一网络上的另一台计算机访问所需的任何步骤将会很有帮助。

Here is what I have done so far: 这是我到目前为止所做的:

  1. Created an ASP MVC 3 application with VS2010 用VS2010创建了一个ASP MVC 3应用程序
  2. Built and Run 建造和运行
  3. Installed IIS 安装IIS
  4. In IIS - "Added Application" on "Default Web Site" with the Alias: "Hello" 在IIS中 - 使用别名在“默认网站”上添加“应用程序”:“Hello”

    4a. 4A。 "Hello" runs on the DefaultAppPool, .Net 4.0; “Hello”在DefaultAppPool上运行,.Net 4.0; Integrated Pipeline 综合管道

    4b. 4B。 "Hello" has the physical path C:\\inetpub\\Hello “Hello”具有物理路径C:\\ inetpub \\ Hello

  5. In VS2010 - right clicked the project and selected "Publish", using FTP 在VS2010中 - 右键单击​​项目并使用FTP选择“发布”
  6. web browser: navigate to "localhost/Hello" 网络浏览器:导航到“localhost / Hello”

500.19 - Internal Server error: 500.19 - 内部服务器错误:

Config Error: This configuration section cannot be used at this path. This happens when
the section is locked at a parent level. Locking is either by default 
(overrideModeDefault="Deny"), or set explicitly by a location tag with 
overrideMode="Deny" or the legacy allowOverride="false"

Config File: 配置文件:

\\?\C:\inetpub\wwwroot\web.config

Requested URL: 请求的网址:

http://localhost:80/Hello

Physical Path: 物理路径:

C:\inetpub\Hello

Config Source: 配置来源:

68: <validation validateIntegratedModeConfiguration="false" />

69: <modules runAllManagedModulesForAllRequests="true" />

70: </system.webServer>

Download and install ASP MVC 3 下载并安装ASP MVC 3

Create an MVC3 Hello World App in Visual Studio 在Visual Studio中创建MVC3 Hello World应用程序

Install IIS from the “Windows Features” / “Turn Windows features on or off” in Windows. 在Windows中从“Windows功能”/“打开或关闭Windows功能”安装IIS。

Next, you need to configure a website in IIS. 接下来,您需要在IIS中配置网站。 I created one on port 81. Open IIS Manager, and “Add a Website” to the “Sites” node. 我在端口81上创建了一个。打开IIS管理器,并将“添加网站”添加到“站点”节点。

For this website, I created this on D:\\WebSite, and configured it to run on DefaultAppPool, configured for .NET 4.0, on port 81. 对于这个网站,我在D:\\ WebSite上创建了它,并将其配置为在端口81上在.NET 4.0上配置的DefaultAppPool上运行。

Most of the time, IIS is installed after installing the .NET Framework, so you'll need to run some commands to register ASP.NET on IIS. 大多数情况下,IIS是在安装.NET Framework之后安装的,因此您需要运行一些命令来在IIS上注册ASP.NET。

start cmd.exe as an administrator and run aspnet_regiis -i in C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319 以管理员身份启动cmd.exe并在C:\\ Windows \\ Microsoft.NET \\ Framework64 \\ v4.0.30319中运行aspnet_regiis -i

Initially, I had some trouble publishing the project to the destination but for whatever reason, Publish method: “FTP” to Target Location “D:\\WebSite” seems to work quite well and publish only the minimum required files. 最初,我在将项目发布到目的地时遇到了一些麻烦,但无论出于何种原因,发布方法:“FTP”到目标位置“D:\\ WebSite”似乎运行良好,只发布所需的最少文件。

traditionally you could only deploy to your server using ftp. 传统上,您只能使用ftp部署到您的服务器。 Though it doesn't make a lot of sense to ftp to a server which runs locally. 虽然ftp对于本地运行的服务器没有多大意义。 However Microsoft recently introduce the Web Deployment Tool which works really well. 但是,微软最近推出了可以很好地运行的Web部署工具 Once you install them then you have the option of creating a deployable package 安装后,您可以选择创建可部署的软件包

在“发布”对话框中,选择“ 文件系统”选项而不是“FTP”,并为其指定在IIS中设置的路径

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

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