部署ASP.net MVC程序到IIS
2014-12-02 19:23
531 查看
转:/content/4625505.html
在网上找到一个table,列举了不同的操作系统对应的IIS版本以及配置MVC时的说明。
从表中可以总结出:
1.IIS7.0之前的版本,需要特殊配置,因为现有IIS,后来才开发的MVC模块
2.IIS7.0的classic mode,适合之前的版本兼容的,需要特殊配置
3.补充: Windows 7 和window server 2008 R2是IIS7.5,IIS的版本越新,配置越简单(这个是必然的)
我觉得以后遇上IIS6.0的机会很少了,所以也不必理会,只要知道IIS7的Integrated mode如何配置就可以了。
1.安装好IIS后,添加一个新的网站:
![](http://pic002.cnblogs.com/images/2012/135560/2012081514070581.png)
注意新建的website的binding不要与原有website冲突,Default Web Site使用的80端口。
新建的website都会自动创建App pool,它的作用是隔离其它的App pool,各个web site不会互相影响,一个crash了,其它还能继续。
2.在Application Pools下编辑刚刚创建的App pool:
![](http://pic002.cnblogs.com/images/2012/135560/2012081514075051.png)
这里选择.NET的版本和pipeline mode,就是前面说的Integrated mode和classic mode
3.在VS2010中publish
在web project上右键,publish
![](http://pic002.cnblogs.com/images/2012/135560/2012081514080770.png)
在弹出的Publish Web对话框里输入URL和website名,点击Publish
![](http://pic002.cnblogs.com/images/2012/135560/2012081514082543.png)
刷新IIS,可以看到已经部署成功
4.打开浏览器访问,遇到的问题及解决方案:
出现403.14Forbidden错误
需要运行命令:%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir
原因是先安装的.net framework,后安装的iis,需要将asp.net的模块注册到IIS
![](http://pic002.cnblogs.com/images/2012/135560/2012081514064457.png)
An attempt to attach an auto-named database for file .mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
使用mdf文件然后直接attach到sql server express这种方式的,可能会遇到这个错误,这个需要将User Instance=True这个属性加到connection string中
可以直接编辑web.config文件,也可以在IIS的web site的Features View页面的Connection Strings配置项修改
![](http://pic002.cnblogs.com/images/2012/135560/2012081514061417.png)
![](http://pic002.cnblogs.com/images/2012/135560/2012081514063035.png)
Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
需要修改app pool的Identity,换成NewworkService,在App pool的Advanced Settings页面修改
![](http://pic002.cnblogs.com/images/2012/135560/2012081514053653.png)
![](http://pic002.cnblogs.com/images/2012/135560/2012081514055156.png)
Windows7的bug
这个是折腾我最久的一个issue,我实在win7开发的,部署后通过浏览器始终无法打开网页,也看不到任何错误。后来在windows server2008 R2上试了下,一点问题木有,后来在《Pro ASP.NET MVC 2 Framework, Second Edition》这本书找到了答案:
If you’re trying to deploy to IIS 7.5 on Windows 7 for development purposes, you may also need to click Start, type turn windows features on or off, press Enter, and then enable Internet Information Services
在网上找到一个table,列举了不同的操作系统对应的IIS版本以及配置MVC时的说明。
IIS version | Windows version | Remarks |
IIS 7.0 (integrated mode) | Windows Server 2008 Windows Vista (except Home Basic) | No special configuration required |
IIS 7.0 (classic mode) | Windows Server 2008 Windows Vista (except Home Basic) | Special configuration required to use URL routing |
IIS 6.0 | Windows Server 2003 | Special configuration required to use URL routing |
IIS 5.1 | Windows XP Professional | Special configuration required to use URL routing |
IIS 5.0 | Windows 2000 | Special configuration required to use URL routing |
1.IIS7.0之前的版本,需要特殊配置,因为现有IIS,后来才开发的MVC模块
2.IIS7.0的classic mode,适合之前的版本兼容的,需要特殊配置
3.补充: Windows 7 和window server 2008 R2是IIS7.5,IIS的版本越新,配置越简单(这个是必然的)
我觉得以后遇上IIS6.0的机会很少了,所以也不必理会,只要知道IIS7的Integrated mode如何配置就可以了。
1.安装好IIS后,添加一个新的网站:
![](http://pic002.cnblogs.com/images/2012/135560/2012081514070581.png)
注意新建的website的binding不要与原有website冲突,Default Web Site使用的80端口。
新建的website都会自动创建App pool,它的作用是隔离其它的App pool,各个web site不会互相影响,一个crash了,其它还能继续。
2.在Application Pools下编辑刚刚创建的App pool:
![](http://pic002.cnblogs.com/images/2012/135560/2012081514075051.png)
这里选择.NET的版本和pipeline mode,就是前面说的Integrated mode和classic mode
3.在VS2010中publish
在web project上右键,publish
![](http://pic002.cnblogs.com/images/2012/135560/2012081514080770.png)
在弹出的Publish Web对话框里输入URL和website名,点击Publish
![](http://pic002.cnblogs.com/images/2012/135560/2012081514082543.png)
刷新IIS,可以看到已经部署成功
4.打开浏览器访问,遇到的问题及解决方案:
出现403.14Forbidden错误
需要运行命令:%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir
原因是先安装的.net framework,后安装的iis,需要将asp.net的模块注册到IIS
![](http://pic002.cnblogs.com/images/2012/135560/2012081514064457.png)
An attempt to attach an auto-named database for file .mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
使用mdf文件然后直接attach到sql server express这种方式的,可能会遇到这个错误,这个需要将User Instance=True这个属性加到connection string中
可以直接编辑web.config文件,也可以在IIS的web site的Features View页面的Connection Strings配置项修改
![](http://pic002.cnblogs.com/images/2012/135560/2012081514061417.png)
![](http://pic002.cnblogs.com/images/2012/135560/2012081514063035.png)
Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.
需要修改app pool的Identity,换成NewworkService,在App pool的Advanced Settings页面修改
![](http://pic002.cnblogs.com/images/2012/135560/2012081514053653.png)
![](http://pic002.cnblogs.com/images/2012/135560/2012081514055156.png)
Windows7的bug
这个是折腾我最久的一个issue,我实在win7开发的,部署后通过浏览器始终无法打开网页,也看不到任何错误。后来在windows server2008 R2上试了下,一点问题木有,后来在《Pro ASP.NET MVC 2 Framework, Second Edition》这本书找到了答案:
If you’re trying to deploy to IIS 7.5 on Windows 7 for development purposes, you may also need to click Start, type turn windows features on or off, press Enter, and then enable Internet Information Services
相关文章推荐
- 部署ASP.net MVC程序到IIS
- windows server 2012 r2 iis8.5 部署asp.net mvc4/5程序小结
- windows server 2012 r2 iis8.5 部署asp.net mvc4/5程序小结
- 部署ASP.net MVC程序到IIS
- asp.net mvc 项目IIS 部署未加载程序集问题原因总结
- 在IIS 5.1下如何部署ASP.NET MVC 程序
- 在IIS6.0中部署asp.net mvc程序
- ASP.NET MVC1.0项目部署到 IIS 5.1的步骤
- Asp.net MVC项目的部署(一):IIS以及Asp.net与IIS相关的部分
- IIS 6.0部署ASP.NET MVC 2.0方法整理
- 部署 外网 ASP.NET程序时, IIS安全性 配置 -摘自网络
- 海洋工作室——网站建设专家:如何在IIS6.0中部署asp.net mvc程序
- (转)asp.net MVC 3.0 在各个版本IIS中的部署
- IIS 6.0上部署ASP.NET MVC2.0
- 虚拟主机运行Asp.net MVC2程序体验(在不同版本的 IIS 上使用 ASP.NET MVC(转),付程序示例 )
- iis 上部署asp.net程序出错排查
- 以levenblog为例,尝试在linux+mono平台上部署asp.net mvc程序
- 如何在IIS6.0中部署asp.net mvc程序
- 如何在IIS6.0中部署asp.net mvc程序
- IIS 6.0部署ASP.NET MVC 2.0的方法