我必須部署到IIS Web服務器的兩個Web應用程序,他們兩人都是
在同一IIS服務器上的同一個應用程序池
,但單獨的應用程序池。他們都使用Windows AD組進行身份驗證,因此將SiteA用戶添加到SiteA AD Group,並將SiteB用戶添加到SiteB AD Group,並允許他們訪問各自的站點。這些網站沒有任何關聯,並且完全相互獨立。在全球的的Application_Start,他們有這樣的:部署C#MVC的Web應用程序運行時錯誤
站點A
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
log4net.Config.XmlConfigurator.Configure();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
var rolesDictionary = ((SiteAMembershipProvider)(Membership.Provider)).InitialisePermissionDictionary();
HttpRuntime.Cache.Insert(
/* key */ "RolesDictionary",
/* value */ rolesDictionary,
/* dependencies */ null,
/* absoluteExpiration */ Cache.NoAbsoluteExpiration,
/* slidingExpiration */ Cache.NoSlidingExpiration,
/* priority */ CacheItemPriority.NotRemovable,
/* onRemoveCallback */ null);
}
網站B
protected void Application_Start()
{
log4net.Config.XmlConfigurator.Configure();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
var rolesDictionary = ((SiteBMembershipProvider)(Membership.Provider)).InitialisePermissionDictionary();
HttpRuntime.Cache.Insert(
/* key */ "RolesDictionary",
/* value */ rolesDictionary,
/* dependencies */ null,
/* absoluteExpiration */ Cache.NoAbsoluteExpiration,
/* slidingExpiration */ Cache.NoSlidingExpiration,
/* priority */ CacheItemPriority.NotRemovable,
/* onRemoveCallback */ null);
}
只有我展示這個原因是因爲我懷疑這是在哪裏問題在於,但事實上我不知道。
的問題是,這兩個網站的工作,因爲他們應該獨立。因爲我在兩個AD組中都可以開始任何一個並獲得訪問權限。問題是,當我在我的瀏覽器一個網站打開,然後打開其他的,我得到一個運行時錯誤:
運行時錯誤
Description: An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated.
出現這種情況,無論我先打開哪個網站,所以如果我打開站點A ,它會打開罰款,然後如果我在另一個選項卡中打開SiteB,它將產生SiteB的錯誤。反之亦然,如果我先打開SiteB,然後打開SiteA,它將爲SiteA產生該錯誤。我可以單獨打開一個,但必須關閉瀏覽器和瀏覽器的所有實例,才能打開其他瀏覽器。所以我認爲這與緩存無關,但我無法確定。當應用程序啓動時,在全局的Application_PostAuthenticateRequest方法中,標識用戶,並且如果必要的AD組的一部分,它們的詳細信息將被添加到Context.User中。它在兩個應用程序中的工作方式完全相同。任何人都知道爲什麼會發生這種情況?是否這兩個應用程序試圖保存到Context.User時,都是同時啓動?
編輯:
忘了補充,當我在開發環境中同時運行兩個,他們都工作。
EDIT2:
安徒生皮門特爾的建議,我檢查在事件查看器的應用程序日誌,並有以下錯誤:
Exception information: Exception type: CryptographicException Exception message: Error occurred during a cryptographic operation. at System.Web.Security.Cryptography.HomogenizingCryptoServiceWrapper.HomogenizeErrors(Func`2 func, Byte[] input) at System.Web.Security.FormsAuthentication.Decrypt(String encryptedTicket) at AuditTracker.MvcApplication.Application_PostAuthenticateRequest(Object sender, EventArgs args) at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
所以糾正我,如果我錯了,但似乎SiteB正在嘗試解密已由SiteA加密的身份驗證Cookie,因此具有不同的密鑰,這就是它正在崩潰的地方。是對的嗎?
檢查事件查看器中的應用程序日誌以獲取有關該異常的更多信息。 –
是否這樣做,請參閱上面的修改。 – necrofish666
您是否檢查過[this](http://stackoverflow.com/questions/25857577/error-occurred-during-a-cryptographic-operation-when-decrypting-forms-cookie)? –