ASP.NET VB.NET Search button on masterpage doesn’t navigate to the correct directory

I have a search input and button in a masterpage that I would like to redirect to the same directory that the user is currently in. If user is in, i would like the redirect to be If the user is in, I would like the redirect to be

I can only get it to redirect to one directory or the other.

I have tried HttpContext.Current.Request.PhysicalApplicationPath, and several other HttpContext ideas that do not work to get the current folder directory a user is in.

Response.Redirect("~/Manage/search.aspx?searchstring=" + qSearch.Text)
Response.Redirect("~/Field/search.aspx?searchstring=" + qSearch.Text)


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I haven’t checked with a master page, but I think it’s easier than it seems. Since you always want the search.aspx page in the current directory, you don’t have to specify the directory.

Response.Redirect("search.aspx?searchstring=" + qSearch.Text)

I think that should always go to the nearest search page.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x