Dev Environment: .Net 4.0 + IIS 7 + visual studio 2010 + win 7
经历:
1. 在visual studio 2010里create web application project: select menu "File > New > Project...", select "Visual c# > Web > ASP.NET Web Application"
2. run it in debug mode, it works fine with a random port. 应该是visual studio里有一个内置的iis server.
3. 现在想把该web app放到production IIS上。我天真地以为把整个project folder copy到wwwroot目录下就OK了,但其实不行。需要在IIS Manager里创建一个application, 然后再把project里的东东复制到该application指向的physical path里。具体做法是:
step 1. Open IIS Manager. click start button, and then right click "Computer", select "Manage". And access "Services and Applications > IIS" node
step 2 right click web site node (e.g. "Default Web site"), select "Add Application...". (注意:若选"Add Virtual Directory"是不行的!)
step 3 input"Alias", select ASP.NET 4.0 as Application Pool, and set "Physical Path" to 你将放置web app东东的path,click OK.
注意:如果把Physical Path直接指向visual studio project folder path,则可能会出现下列错误。这应该是由于project folder permission导致的。具体参看http://support.microsoft.com/kb/942055
Server Error in Application "application name"
HTTP Error 500.19 – Internal Server Error
HRESULT: 0x80070005
Description of HRESULT
The requested page cannot be accessed because the related configuration data for the page is invalid.
step 4 把web app的所有东东复制到step 3设置的"Physical Path" 里即可。
另外还有一个办法是直接在visual studio里直接publish web app to IIS,参看下面文章的Approach 2
http://www.shubho.net/2011/01/quick-deployment-of-aspnet-applications.html