【发布时间】:2011-11-01 07:55:13
【问题描述】:
我正在研究使用 WIF 在 EPiServer 上运行的客户站点的部分上识别用户的可能性。我已经设法让 WIF 开始使用以下帖子:
如果你设置了这个效果很好
<authorization>
<deny users="?"/>
</authorization>
在 web.config 中,发出所有请求都需要经过身份验证的用户。但是,我们想使用 EPiServer 来区分哪些内容应该可供匿名用户和经过身份验证的用户使用。问题是,我就是无法让它工作。
当我启用 WIF 并且不设置 deny users="*" 时,EPiServer 会在启用 WIF 以执行重定向之前启动并向响应流输出一些文本:
HTTP/1.1 401 Unauthorized
Cache-Control: private
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Tue, 01 Nov 2011 07:51:04 GMT
Connection: close
Access denied.
</pre></table></table></table></table></table></font></font></font></font></font></i></i></i></i></i></b></b></b></b></b></u></u></u></u></u><p> </p><hr>
当 WIF 尝试重定向到 STS 时,这会导致以下错误:
“/”应用程序中的服务器错误。
发送 HTTP 标头后无法重定向。
描述:执行过程中发生了未处理的异常 当前的网络请求。请查看堆栈跟踪以获取更多信息 有关错误的信息以及它在代码中的来源。
异常详细信息:System.Web.HttpException:之后无法重定向 HTTP 标头已发送。
来源错误:
在执行过程中产生了一个未处理的异常 当前的网络请求。有关原产地和位置的信息 可以使用下面的异常堆栈跟踪来识别异常。
堆栈跟踪:
[HttpException (0x80004005): HTTP headers 后无法重定向 已发送。] System.Web.HttpResponse.Redirect(String url, Boolean endResponse) +8712587
Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.RedirectToIdentityProvider(字符串 uniqueId,字符串 returnUrl,布尔值持久化)+249
Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.OnEndRequest(对象 发件人,EventArgs 参数)+438
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
我已经搜索了高和低,以便能够覆盖此行为。在 EPiServer.dll 中,我发现以下地方输出的文本与输出内容相似:
AccessDeniedDelegateHandler.cs,方法BrowserLogonAccessDenied(object sender):
internal static void BrowserLogonAccessDenied(object sender)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Status = "401 Unauthorized";
HttpContext.Current.Response.Write("Access denied.");
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}
据我所知,这段代码是从以下两个地方调用的:
-
EPiServer.Global,方法protected virtual void HandleAccessDenied() -
EPiServer.PageBase,方法public virtual void AccessDenied()
我试图在Global.asax 中覆盖HandleAccessDenied,并在我的页面模板中覆盖AccessDenied。但是,仍会输出“拒绝访问”文本。看起来好像我的页面模板中的 AcccessDenied 覆盖正在触发,但是,HandleAccessDenied 的覆盖似乎没有触发。
关于这里可能出现什么问题的任何提示?
【问题讨论】:
标签: episerver wif episerver-6