我有一个简单的实现,可以实例化OpenIdRelyingParty,然后调用RedirectToProvider。它在1和1托管环境中运行良好,在Cassini上运行也很好(Visual 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();
}
} 错误信息是神秘的,关于纠正错误的知识库文章更是如此。
正在尝试执行什么操作的
H 112该策略中有什么?H 213H 114在哪里可以找到或更改它?H 215F 216
谢谢。
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:02
很可能是OpenID在登录用户时必须发出的出站HTTP请求。如果您的web.config文件将站点设置为在中等信任下运行,请尝试将其设置为高度信任或完全信任。
中介信任在宿主环境中工作,而不是“在家里”工作,原因是ASP.NET附带的默认媒体信任配置不允许出站HTTP请求,但大多数共享宿主环境都会修改此设置,从而允许媒体信任。
在国内,最简单的解决方法是提高web.config文件中的信任级别。
https://stackoverflow.com/questions/9097881
复制相似问题