Posted By

LeeRJohnson on 01/23/09


Tagged

redirect page c aspnet 301


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

dzone
benrudolph


ASP.NET 301 Redirect Page


 / Published in: ASP
 

URL: ASP.NET 301 Redirect Page

  1. <%@ Page Language="C#" Title="ASP.NET 301 Redirect Page" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <script runat="server">
  4. //Url to redirect this page to
  5. Uri urlRedirect = new Uri("http://snipplr.com/view/11473/aspnet-301-redirect-page/");
  6.  
  7. private void Page_Load(object sender, System.EventArgs e)
  8. {
  9. //Set Response
  10. Response.Status = "301 Moved Permanently";
  11. Response.AddHeader("Location", urlRedirect.AbsoluteUri);
  12. }
  13.  
  14. </script>
  15.  
  16. <html xmlns="http://www.w3.org/1999/xhtml">
  17. <head runat="server">
  18. <title><%= Page.Title.ToString() %></title>
  19. </head>
  20. <body>
  21. <p>This page has moved to <a href="<%= urlRedirect.ToString() %>" runat="server" /></p>
  22. </body>
  23. </html>

Report this snippet  

You need to login to post a comment.