我有一个搜索输入和母版页中的按钮,我想要重定向到用户当前所在的同一目录。如果用户在myurl.com/Manage/default.aspx中,我希望重定向为myurl.com/Manage/search.aspx。如果用户在myurl.com/Field/default.aspx中,我希望重定向为myurl.com/Field/search.aspx。
我只能让它重定向到一个或另一个目录。
我尝试过HttpContext.Current.Request.PhysicalApplicationPath,和其他几种HttpContext方法,它们无法获得用户所在的当前文件夹目录。
Response.Redirect("~/Manage/search.aspx?searchstring=" + qSearch.Text)
or
Response.Redirect("~/Field/search.aspx?searchstring=" + qSearch.Text)
发布于 2020-09-18 10:41:03
我还没有检查过母版页,但我认为它比看起来更容易。因为您总是希望search.aspx
页面位于当前目录中,所以不必指定目录。
Response.Redirect("search.aspx?searchstring=" + qSearch.Text)
我认为这应该总是转到最近的搜索页面。
https://stackoverflow.com/questions/63951785
复制