이 문서는 세션 상태에 액세스 할 수 있도록 다른 이벤트 처리기에서 ELMAH 오류 처리기 포장하는 방법에 대해 설명을 Global.asax에서
http://groups.google.com/group/elmah/msg/a0aa776d348ba97e
을, 당신은 무언가를 가질 수 같은 다음
protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
{
// Get the filename being requested
string filename = Path.GetFileName(Request.Path).ToLower();
// Verify that a user is logged in by checking the session
bool isValid = (HttpContext.Current.Session["User"] != null);
// Throw error if invalid
if (filename == "elmah.axd" && !isValid)
throw new SecurityException("Access to elmah.axd is denied");
}
표준 ELMAH 핸들러가 IRequiresSessionState 또는 IReadOnlySessionState를 구현하지 않기 때문에 다른를 만들어야합니다 위에서 언급 한 링크에서 설명한대로이를 감싸는 이벤트 핸들러. 그렇지 않으면 Application_PreRequestHandlerExecute 이벤트에서 세션에 액세스 할 수 없습니다.
출처
2010-03-19 18:23:47
Mun