2011-03-16 81 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")