简体   繁体   English

母版页上的 ASP.NET VB.NET 搜索按钮根据成员身份和当前目录更改目录

[英]ASP.NET VB.NET Search button on masterpage change directory depending on membership role and current directory

Using masterpage, I have an input and button I need to be able to do navigation between the levels.使用母版页,我有一个输入和按钮,我需要能够在级别之间进行导航。 I've tried我试过了

HttpContext.Current.Request.PhysicalApplicationPath, and several other HttpContext ideas that do not work to get the current folder directory a user is in. How do I get the current directory a user is in? HttpContext.Current.Request.PhysicalApplicationPath,以及其他几个 HttpContext 的想法,它们无法获取用户所在的当前文件夹目录。如何获取用户所在的当前目录?

For example, I need to know if user is in "level2" directory, or if in "Level3" directory, or if in root directory.例如,我需要知道用户是否在“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

Similar to what VDWWD said:类似于 VDWWD 所说的:

string[] levels = Request.Url.AbsolutePath.Split('/');

If you Split() at the slash mark ('/') , you get 4 segments如果在斜杠('/')Split() ('/') ,则会得到 4 个段

myurl.com/level2/Level3/default.aspx
     1      2      3         4

So:所以:

if(levels.Length == 4)
{
    // you're at level 3. the level is the always the length-1.
}

Using the code from the answer above:使用上面答案中的代码:

Dim levels As String() = Request.Url.AbsolutePath.Split("/"c)
For Each value In Levels
   If value = "Field" Then
      Response.Redirect("~/Field/orders.aspx?OrderNo=" + qSearch.Text)
   ElseIf value = "Manage" Then
      Response.Redirect("~/Manage/orders.aspx?OrderNo=" + qSearch.Text)
   End If
Next

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM