Reputation: 491
Is there a way using ASP.NET that I can 302 (temporary) redirect all pages on the website to the homepage (obviously not redirecting the homepage)?
Upvotes: 4
Views: 2170
Reputation: 32551
Add this in your Global.asax file:
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Request.Url.LocalPath != "/Home.aspx")
HttpContext.Current.Response.Redirect("Home.aspx");
}
From the HttpResponse.Redirect Method (String) article:
ASP.NET performs the redirection by returning a 302 HTTP status code.
Upvotes: 5