在部署ASP.NET 网站到IIS上的时候,部署完成后,访问页面http://localhost/UserCenter/user.aspx,却抛出了异常。此时检测是否部署成功,可以在根目录下写一个用于测试的文本文件text.txt,然后访问这个文件http://localhost/UserCenter/test.txt ,如果能看到这个文件的内容,说明部署上没有出问题,可能是代码出问题。
异常提示:
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
异常截图
造成这个问题的原因是,在本机上有个多个.NET版本,所以相应有多个ASP.NET Version的类库。而现在我们的Application Pool用的是4.0的版本,但是这个版本没有在IIS上进行注册,所以报出了这个错误。现在我们需要做的,就是注册这个4.0的ASP.NET Version. 在C:\WINDOWS\Microsoft.NET\Framework64\v4.0.xxxx目录下找到IIS Registration Tools,即Aspnet_regiis.exe,然后用DOS窗口的形式启动它,aspnet_regiis -i 详细信息参照MSDN http://msdn.microsoft.com/en-us/library/k6h9cz8h%28VS.80%29.aspx
运行结果
此时,重启Application Pool 与网站,就可以看到正常的aspx渲染后的页面了。