首先說明程式和環境:
應用程式 : VS 2008 + MVC 2.0
釋出環境 : Widnows 2008 R2 Server + IIS 7.5
問題說明 : 該mvc應用程式在 xp/server 2003 + IIS 6 下面工作正常,但是當釋出到 IIS 7.5 環境時,出現如下錯誤
(An internal error occurred.)
(System.Security.Cryptography.CryptographicException: An internal error occurred.
at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)
at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[] rawData)
... ... ...
或者會提示出現 404.0 錯誤,究其原因,應該是 MVC 子產品,或者賬戶權限的問題,現解決方法如下:
解決方法:
1. 確定安裝了 .Net Framework 3.5.1 Features
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiYWan5CdhxUawYDN1ETN4IzMx8FMvwlNvwlMwITMwIzLcRnbl1GajFGd0F2LcRXZu5ibkN3YukGavw1LcpDc0RHaiojIsJye.gif)
2. 建立 application Pool
建立的 application pool 名為“Test Web Site“,屬性設定如下
3. 添加 MVC 應用程式
并設定 "mvcSite" 應用程式的Application Pool 為建立的 "Test Web Site".
4. 添加 mvc 2 Handler Mappings.
輕按兩下 "Handler Mappings", 然後單擊右上角 "Add Wildchard Script Map ..."
5. 必要時,重新開機 站點 或者 Application Pool, 或者重新安裝 .net framework, 如運作指令:
C:\Windows\Microsoft.NET>%windir%/Microsoft.NET/Framework/v4.0.30319/aspnet_regiis.exe -i
經過上述操作,正常情況下是可以工作的。