2011-03-16 91 views
0

我们有一家商店,我们与一家公司签约进行修改。他们增加了以下我们Global.asax文件:从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 &检查= V7Xc1BsH913V

如果有人可以帮我修改全局文件我将不胜感激。我试图添加
exFilePath.EndsWith(“〜/ Passwordhelp.aspx”)
但这并不奏效。

感谢

回答

1

更改您如果更喜欢:

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”检查之前。

+0

完美!感谢你的解释,它给了我一些额外的有用的东西来了解全局文件。 – Deverill 2011-03-17 16:46:35

0

更换EndsWithStartsWith

0

下加入条件:

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