开发者

Redirect from Global.asax file

we have a store that we contracted with a company to modify. They added the following to our Global.asax file:

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();
    }
}

The purpose is to take anyone going to one of our pages to a login screen unless they are going to these folders which do not need the login protection.

I now need to let them go to http://[mysite]/vendorstore/PasswordHelp.aspx?Key=123&Check=V7Xc1BsH913V

If anyone could help me modify the global file I would be grateful. I tried to add

|| exFilePath.EndsWith("~/Passwordhelp.aspx")

but that didn't work.

Thanks


Change your if to be more like:

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")
 )

make sure you're using lowercase ("passwordhelp.aspx") and make sure it's before your !exeFilePath.EndsWith(".aspx") and ".ashx" checks.


Replace EndsWith with StartsWith.


Add the following to the condition:

|| exFilePath.StartsWith("~/vendorstore/passwordhelp")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜