允許我有一個簡單的實現方式,其中我實例OpenIdRelyingParty然後調用RedirectToProvider的操作。它在1and1託管環境以及Cassini(Visual Studio 2010)上運行良好。然而,當我在我的PC(Windows 7)中的部署到IIS,我得到一個安全異常:安全例外 - 該應用程序試圖執行安全策略
「應用程序試圖執行安全策略不允許的操作要授予此應用程序。需要的權限請聯繫您的系統管理員或在配置文件中更改應用程序的信任級別。「
某處下面的代碼:
protected void Button1_Click(object sender, ImageClickEventArgs e)
{
string realm = WebConfigurationManager.AppSettings["Realm"];
Uri returnPath = new Uri(new Uri(realm), "welcome.aspx");
using (OpenIdRelyingParty openId = new OpenIdRelyingParty())
{
IAuthenticationRequest request = openId.CreateRequest("https://www.google.com/accounts/o8/id",
new DotNetOpenAuth.OpenId.Realm(realm), returnPath);
request.RedirectToProvider();
}
}
錯誤消息是神祕和整頓它的知識庫文章更是如此。
- 誰試圖執行什麼操作?
- DotNetOpenAuth試圖訪問什麼?
- 誰或不相信誰?
- 它正在談論什麼安全策略?
- 這項政策是什麼?
- 我在哪裏可以找到它或更改它?
謝謝。
2012年5月2日
按照要求,這裏是調用堆棧:
[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) +150
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) +100
System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) +283
System.Security.PermissionSetTriple.CheckSetDemand(PermissionSet demandSet, PermissionSet& alteredDemandset, RuntimeMethodHandle rmh) +69
System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandle rmh) +150
System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet) +30
System.Threading.CompressedStack.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet) +40
System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant, CompressedStack securityContext) +123
System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant) +54
這個異常的調用堆將非常有幫助。 – 2012-02-02 17:42:11