2012-02-01 66 views
0

允许我有一个简单的实现方式,其中我实例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 
+0

这个异常的调用堆将非常有帮助。 – 2012-02-02 17:42:11

回答

0

最有可能是出站HTTP请求的OpenID必须登录用户如果您的网络.config文件将站点设置为在中等信任下运行,尝试将其颠倒为高或完全信任。

中等信任在托管环境中工作但不在“在家”的原因是因为ASP.NET附带的默认中等信任配置不允许出站HTTP请求,但大多数共享主机环境都会修改此设置,因此中等信任允许它。

在家里,来解决这个问题最简单的方法是提高你的web.config文件的信任级别。

+0

它已经满了。 :( – 2012-05-02 02:41:57

+0

很奇怪,在那之前我还没有看到过。 – 2012-05-03 14:07:15