項目使用VS2010.MVC3.0開發,服務器的操做系統是Windows server 2008,下面我就講下部署的步驟。html
1.安裝IISweb
打開服務器管理器->角色->添加角色->勾選Web服務器(IIS),而後一直下一步,完成安裝便可,windows server 2008安裝的是IIS7windows
2.使用快捷鍵WIN+R,即打開運行窗口,而後輸入「inetmgr」,快速打開IIS安全
3.IIS左側有個樹列表,找到「網站」節點,右鍵新建網站,填寫網站名稱,綁定端口,還有項目的物理路徑。這裏須要說一下,在建立網站的同時,你能夠在應用程池列表中選擇一個來託管項目,服務器
若是不選的話會自動生成一個與你網站名稱相同的應用程序池,以下圖所示。session
應用程序池的.netframework版本根據你的項目而定,若是你的項目是用.netframework4.0開發的,用v2.0就會出錯。app
當我滿心歡喜的輸入url,錯誤展示在我面前。下面是錯誤的內容。asp.net
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".ide
當客戶端瀏覽時會出現這個錯誤,但這其實並非真的錯誤,上面的意思主要是告訴咱們若是程序出錯了,讓咱們指定一個錯誤頁面,即便我加了<customErrors>,依舊報錯,要像發現真正的問題,仍是得打開服務器上的IIS,網站
右側有個操做欄,瀏覽網站,看到了吧,點擊它,立刻拋出另外一個錯誤,倍兒爽。
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_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection. 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, PublicKeyToken=31bf3856ad364e35」或它的某一
解決方案:點我去下載MVC3,下載完安裝完,這個問題就解決了。
鬆口氣,瀏覽繼續報錯。。好吧IIS你贏了
譯器錯誤消息: CS0016: 未能寫入輸出文件「c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\2e9aca09\f067b5c4\App_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,終於出現了熟悉的頁面,總算能夠下班回家了!!!!