We have no real context about what you mean by "redirect by themselves", "get an error index" or "even separated the code between page preload and page load". But just a quick glance at your code it seems like you're trying to include an id
query string value as part of your redirect and that code isn't correct. If there is no query string (e.g. http://localhost
) then you'll get an OOR error because QueryString
is empty. There is no first element.
if (Request.QueryString.Count > 0) {
Response.Redirect("Request.aspx?id=" + Request.QueryString[0]);
} else {
Response.Redirect("Request.aspx");
}
I'm assuming here that this code isn't on the actual Request.aspx
page. If it was then you'd get an infinite loop.