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 myurl.com/Manage/default.aspx, i would like the redirect to be myurl.com/Manage/search.aspx. If the user is in myurl.com/Field/default.aspx, I would like the redirect to be myurl.com/Field/search.aspx.
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) or 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.
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.