asp.net - 主页上的 ASP.NET VB.NET 搜索按钮根据成员角色和当前目录更改目录
问题描述
使用 masterpage,我有一个输入和按钮,我需要能够在各个级别之间进行导航。我试过了
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.
}
推荐阅读
- ubuntu - Lubuntu 上没有显示网络接口
- c# - 使用 C# Windows 窗体在 Visual Studio 中创建新页面
- reactjs - 为什么 create-react-app 需要 root 帐户来创建项目
- c++ - 为什么 g++ 会生成巨大的错误日志?
- ios - 如何在 IOS 12 中用新收到的通知(包含相同的通知 ID)替换推送通知
- java - 当我尝试通过广播连接到互联网时,应用程序停止工作
- java - Butterknife 中的 @OnClick 方法使用 java.lang.BootstrapMethodError 使应用程序崩溃
- linux - 无法在 Red Hat 中安装 openJDK 8
- docker - docker build with jenkins 问题
- android - 当我手动下载 Android Studio 组件时,我应该把它们放在哪里?