今天在腾讯服务器上部署公司的项目,遇到了很多的问题,简直可以用一波未平一波又起来形容。
记录一下,怕自己忘记,顺便也帮助跟我遇到同样问题的人。
项目使用VS2010.MVC3.0开发,服务器的操作系统是Windows server 2008,下面我就讲下部署的步骤。
1.安装IIS
打开服务器管理器->角色->添加角色->勾选Web服务器(IIS),然后一直下一步,完成安装即可,windows server 2008安装的是IIS7
2.使用快捷键WIN+R,即打开运行窗口,然后输入“inetmgr”,快速打开IIS
3.IIS左侧有个树列表,找到“网站”节点,右键新建网站,填写网站名称,绑定端口,还有项目的物理路径。这里需要说一下,在创建网站的同时,你可以在应用程池列表中选择一个来托管项目,
如果不选的话会自动生成一个与你网站名称相同的应用程序池,如下图所示。
应用程序池的.netframework版本根据你的项目而定,如果你的项目是用.netframework4.0开发的,用v2.0就会出错。
当我满心欢喜的输入url,错误展现在我面前。下面是错误的内容。
Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
当客户端浏览时会出现这个错误,但这其实并不是真的错误,上面的意思主要是告诉我们如果程序出错了,让我们指定一个错误页面,即使我加了<customErrors>,依旧报错,要像发现真正的问题,还是得打开服务器上的IIS,
右侧有个操作栏,浏览网站,看到了吧,点击它,马上抛出另一个错误,倍儿爽。
Server Error in '/' Application.
Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same. If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesaspnet_stateParametersAllowRemoteConnection. If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same. If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesaspnet_stateParametersAllowRemoteConnection. If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
这里原理我就不说了,只说解决方案,依旧Win+R,输入"services.msc",打开windows服务列表,找到“ASP.NET 状态服务”,打开这个这个服务并设置为自动。
ok 搞定!!
继续在IIS浏览,打开以后,又你妹报错了
未能加载文件或程序集“System.Web.Helpers, Version=1.0.0.0, Culture=neutral,
未能加载文件或程序集“System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或它的某一
解决方案:点我去下载MVC3,下载完安装完,这个问题就解决了。
松口气,浏览继续报错。。好吧IIS你赢了
译器错误消息: CS0016: 未能写入输出文件“c:WindowsMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Files oot2e9aca09f067b5c4App_Web_login.aspx.cdcab7d2.5bhornew.dll”--“拒绝访问。
解决方案:这个图比较多
C盘的Window目录下找到TEMP文件夹,若没有该文件夹,则Window目录下自己创建一个TEMP文件夹。选择TEMP文件夹点击右键,然后选择属性。
长舒一口气,继续迎接新的报错!!
错误信息 Server Error in ‘/’ Application. Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.
解决方案:这是因为没有注册asp.net4.0,WIN+R 输入"cmd",进入命令行,输入
C:/Windows/Microsoft.NET/Framework/v4.0.30319/aspnet_regiis.exe -i
回车运行,如果读者的服务器是64系统,那么需要使用命令C:/Windows/Microsoft.NET/Framework64/v4.0.30319/aspnet_regiis.exe -i 来运行注册iis。
在忐忑中,输入url,终于出现了熟悉的页面,总算可以下班回家了!!!!