Mar*_*n B 5 c# asp.net elmah exception-handling
我有一个主题页面,主题在http模块中选择.
public void context_PreRequestHandlerExecute(object sender, EventArgs e)
{
Page p = HttpContext.Current.Handler as Page;
if (p != null)
{
//get theme
string theme = GetTheme(HttpContext.Current.Request.Url.Host);
Debug.WriteLine(String.Format("Loading theme {0}", theme));
//set theme of page
p.Theme = theme;
}
}
Run Code Online (Sandbox Code Playgroud)
private const string ELMAH_ERROR_PAGE = "Elmah.ErrorLogPage";
if (p.GetType().FullName != ELMAH_ERROR_PAGE)
{
p.Theme = theme;
}
Run Code Online (Sandbox Code Playgroud)
public void context_PreRequestHandlerExecute(object sender, EventArgs e)
{
Page p = HttpContext.Current.Handler as Page;
if (p != null)
{
//get theme
string theme = GetTheme(HttpContext.Current.Request.Url.Host);
Debug.WriteLine(String.Format("Loading theme {0}", theme));
//set theme of page
p.Theme = theme;
}
}
Run Code Online (Sandbox Code Playgroud)
你有更好的想法或想法吗?
GR
马亭
荷兰人
之前已经回答过您的问题的解决方案:
排除某些页面使用 HTTPModule。
您可以使用 HTTPHandler 而不是 HTTPModule。处理程序允许您在 Web.Config 中声明它们时指定路径。
Run Code Online (Sandbox Code Playgroud)<add verb="*" path="/validate/*.aspx" type="Handler,Assembly"/>如果您必须使用 HTTPModule,您可以只检查请求的路径,如果它是要排除的路径,则绕过验证。