採用負載平衡伺服器的情況下部署兩台站台伺服器,碰到幾個問題及他們的解決辦法。
1. 當將發布好的網站檔案copy到IIS目錄下,配製好IIS對Framework的支援,訪問網站,始終出現Service Unavailable兩個大字,鬱悶....搜尋一番,發現瞭解決辦法:
開啟IIS的websites檔案夾的屬性,然後到Service選項卡,鉤選Run WWW service in IIS 5.0 isolation mode.
如:
這樣設定後,我們的網站在本機終於可以開啟了。
2. 配置第二台Web Server時,按照第一台的步驟部署配置完成,開啟網頁,出現下面的錯誤:This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)
FileLoadException: Could not load file or assembly 'acPDFCreatorLib.Net, Version=3.0.2735.26202, Culture=neutral, PublicKeyToken=8aedc7a81d17941d' or one of its dependencies. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)]
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +211
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
System.Reflection.Assembly.Load(String assemblyString) +25
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +32
這裡引用了一個第三方的程式集做PDF->XPS的轉換。奇怪,第一台伺服器沒有任何問題,部署配置是一樣的,包括檔案都是同一個拷貝,而第二台伺服器出現這個錯誤。最後發現是缺少Visual C++ 2005 Redistributable Package,下載安裝後,問題解決了。
3. 兩台Web Server配置完成了,在本地都可以運行了,下面就訪問事先做好的網域名稱(指向均衡負載伺服器),首頁開啟了,輸入帳號密碼登陸,又出現問題了!大黃頁:Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
經過搜尋找到瞭解決辦法,經如此簡單,web.config做如下修改:<system.web>
<pages enableViewStateMac="false" />
</system.web>
終於好了,一切正常了!