使用母版,我需要一个输入和按钮,以便能够在各个级别之间进行导航。我试过了
HttpContext.Current.Request.PhysicalApplicationPath,以及其他几个HttpContext构想,这些构想无法获取用户所在的当前文件夹目录。如何获取用户所在的当前目录?
例如,我需要知道用户是否在“ level2”目录中,或者是否在“ Level3”目录中,或者是否在根目录中。
myurl.com/default.aspx
myurl.com/Level2/default.aspx
myurl.com/level2/Level3/default.aspx
If user is in Level3 then
Redirect here..
ElseIf user is in Root directory Then
Redirect here..
ElseIf user is in Level2 directory Then
Redirect here..
End If
类似于VDWWD所说:
string[] levels = Request.Url.AbsolutePath.Split('/');
如果您Split()
在斜线标记处('/')
,则会得到4个细分
myurl.com/level2/Level3/default.aspx
1 2 3 4
所以:
if(levels.Length == 4)
{
// you're at level 3. the level is the always the length-1.
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句