friendlessstar 发表于 2015-8-12 11:57:12

asp.net部署上IIS后常见的十个错误

  此文章转载博客亂亂寫 Blog,为了方便日后查寻,特转载过来。

  
  因為在 VS 2010 上跑就是正常,一佈署上 IIS 就掛。( 以下 10 個問題都是上了 iis 後才會出現錯的 )
  結果花了很多的時間找
  
  另外,若是想要知道更詳細的內容,請在 vs 2010 debug 的程序中外掛上 IE 和 IIS( 也許有人會忘了它!補放上來 )

  錯誤訊息一
  「Http 500.19″ internal server error..   There is a duplicate… ’system.web.extensions/scripting/scriptResourceHandler’       section defined….”」
  請參考   http://www.systut.com/?tag=iis7
  解法
  先在 C:\Windows\Microsoft.NET\Framework64\v4.0.30128\Config\machine.config 確認是否有同樣的 seesion 若有,請自行決定要刪 自已的 web.config 或是 machine 的
  小弟最後決定刪 Web.config 的內容如下 ( 請視自已的專案為主 )
  <!--Franma      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">         <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>         <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">         <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>         <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>         <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>         <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>         </sectionGroup>       </sectionGroup>       -->
  
  錯誤訊息二
  Could not load file or assembly 'Tailspin.Infrastructure' or one of its dependencies. 試圖載入格式錯誤的程式。
  解法
  先行確認每一個專案的 Compiler 的 CPU 版本是否一致,不可以有的是 x86 有的是 x64。若 OS 是64Bit 的 AnyCPU 就是指 x64 請全部都調整成一樣的,重新佈署就可以了
  
  錯誤訊息三
  Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
  解法
  這種怪怪的問題應當是 IIS 比 VS 2010 ( or .NET framework ) 還要晚安裝所導致的,
  請用 aspnet_regiis 重新註冊,請注意 .net framework 有 v2 和 v4 請一併註冊

  http://social.msdn.microsoft.com/Forums/en/wcf/thread/39571e42-aca7-469d-8c68-aa59c2da4fcc
  錯誤訊息四
  使用者 'IIS APPPOOL\ASP.NET v4.0' 的登入失敗。
  Exception Details: System.Data.SqlClient.SqlException: 使用者 'IIS APPPOOL\ASP.NET v4.0' 的登入失敗。
  解法
  只要將 connection string 的整合式認證改成,指定帳密就可以了
  
  錯誤訊息五
  Request is not available in this context
  解法
  方法一、直接將 IIS 裡的應用程式集區改成 Classic (傳統)      
  方法二、改寫程式碼,在 Application_Start 中是不允許用 HttpContext的 Request 物件      http://mvolo.com/blogs/serverside/archive/2007/11/10/Integrated-mode-Request-is-not-available-in-this-context-in-Application_5F00_Start.aspx(參考資料)
  錯誤訊息六

  解法

  
  錯誤訊息七
  在 IIS 中的網站裡開啟 「網頁及控制項」出現的

  解法
  將 WebConfig 中的重複項目去掉      
  <!--Franma            <add namespace="System.Linq"/>               <add namespace="System.Collections.Generic" />               -->
  
  錯誤訊息八

  確認 .NET 編譯 是否正常?不然 app_code 會無法 compiler
  解法
  ( 暫 )
  
  錯誤訊息九
  0x80070002 MapRequestHandler

  解法
  因為小弟用的是 VS 2010 而且是用 ASP.NET 4 的 MVC 專案,不過因為有用到 HttpContext所以沒辦法用「整合式」。因此必須在 Controller 後面加上 aspx 後就可以了!( 小弟以為用了 IIS 7.5 後就可以不用理這個問題 Orz )      
  參考網址http://www.asp.net/learn/mvc/tutorial-08-cs.aspx
  「建議!日後最好不要在 Application_Start 中直接去用 HttpContext 不然就沒辦法用 IIS 7 的整合式了」
  
  錯誤訊息十
  MVC 的專案中找不到 jQuery 的 $(document).ready( 錯誤訊息會說找不到物件 )
  解法
  若是 MVC 的專案中用了 master page 且 用了 ~/   沒有效用的話!請改成絕對路徑去引用就好! http://xxxx/xxx/jquery.jsp 之類的
  若是要用程式的話!可以考慮用 context.Request.ApplicationPath
  
  

  最後確定放到 IIS 7.5 後都不會出現任何的錯誤訊息了!!
  這次 MVC 的 URL Route 的客製化範本,一開始真的是讓小弟折磨了好一陣子!
<a target=_top href="http://s1.dotblogs.com.tw/admentorserve.aspx?type=click&z=18&a=11"></a>
  
页: [1]
查看完整版本: asp.net部署上IIS后常见的十个错误