I am new to asp.net and c#. I have set a query string to pass the value to one page to another along with the url path. But once go to this page I will not be able to redirect to any other page.
Here is my code:
Uri url = System.Web.HttpContext.Current.Request.Url;
string urlString = "http://" + url.Authority + "/Projects/SearchResult.aspx/?Keywords=" + TxtSearch.Text;
Response.Redirect(urlString);
Here is the error:
The resource cannot be found. Description: HTTP 404. The resource you
are looking for (or one of its dependencies) could have been removed,
had its name changed, or is temporarily unavailable. Please review
the following URL and make sure that it is spelled correctly.Requested URL: /Projects/Description.aspx/NewPost.aspx
The error is simply indicating the your URL in wrong – the reported url
/Projects/Description.aspx/NewPost.aspxanyway appears to be wrong – it should be either/Projects/Description.aspxor/Projects/NewPost.aspx.As your code is redirecting to completely different page (
/Projects/SearchResult.aspx), you should check that page code for above redirect/transfer.On side note, there are couple of issues in ho you are forming the url:
/?Keywords– you should be using/Projects/SearchResult.aspx?Keywords=Typically, for passing to url within application, you should use
~as application root – that way, you don’t have to worry about host name & root virtual directory (if any). For example, you can writeResponse.Redirect(“~/Projects/SearchResult.aspx?Keywords=” + TxtSearch.Text);