从Global.asax文件重定向

时间:2011-03-16 19:36:21

标签: asp.net

我们有一家商店,我们与公司签订合同进行修改。他们将以下内容添加到我们的Global.asax文件中:

protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
{
    string exFilePath = Request.AppRelativeCurrentExecutionFilePath.ToLower();

if ((!exFilePath.EndsWith(".aspx") && !exFilePath.EndsWith(".ashx"))
     || exFilePath.StartsWith("~/admin")
     || exFilePath.StartsWith("~/js")
     || exFilePath.StartsWith("~/app_themes")
     || exFilePath.StartsWith("~/assets")
     || exFilePath.StartsWith("~/errors")
     || exFilePath.StartsWith("~/fckeditor")
     || exFilePath.StartsWith("~/images")
     || exFilePath.StartsWith("~/layouts")
     || exFilePath.StartsWith("~/webcharts")
     )
{
    return;
}
    else
    {
        AccessHelper.HandleAnonymousUsers();
    }
}

目的是让任何人进入我们的某个页面进入登录界面,除非他们要进入这些不需要登录保护的文件夹。

我现在需要让他们去http:// [mysite] /vendorstore/PasswordHelp.aspx?Key=123&Check=V7Xc1BsH913V

如果有人可以帮我修改全局文件,我将不胜感激。我试着添加
    || exFilePath.EndsWith( “〜/ Passwordhelp.aspx”)
但那没用。

由于

3 个答案:

答案 0 :(得分:1)

将您的if更改为:

if(exeFilePath.EndsWith("/passwordhelp.aspx") || 
  (!exFilePath.EndsWith(".aspx") && !exFilePath.EndsWith(".ashx"))
 || exFilePath.StartsWith("~/admin")
 || exFilePath.StartsWith("~/js")
 || exFilePath.StartsWith("~/app_themes")
 || exFilePath.StartsWith("~/assets")
 || exFilePath.StartsWith("~/errors")
 || exFilePath.StartsWith("~/fckeditor")
 || exFilePath.StartsWith("~/images")
 || exFilePath.StartsWith("~/layouts")
 || exFilePath.StartsWith("~/webcharts")
 )

确保你使用小写字母(“passwordhelp.aspx”)并确保它在你的!exeFilePath.EndsWith(“。aspx”)和“.ashx”检查之前。

答案 1 :(得分:0)

EndsWith替换为StartsWith

答案 2 :(得分:0)

将以下内容添加到条件中:

|| exFilePath.StartsWith("~/vendorstore/passwordhelp")
相关问题