468,483 Members | 2,654 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,483 developers. It's quick & easy.

Can I convert global.asax Application_Error redirects to web.config?

23
Is it possible to convert the following redirects previously in global.asax and global.asa to the web.config file? My server crashed and most of the website works except for the old articles created under .asp extensions.

Web Service Extensions has: Active Server Pages, ASP 1, 2, and 4 "allowed"

Thanks in advance

global.asax:
Expand|Select|Wrap|Line Numbers
  1.     void Application_Error(object sender, EventArgs e) 
  2.     {
  3.         // Code that runs when an unhandled error occurs
  4.         Exception objErr = Server.GetLastError().GetBaseException();
  5.         string err = "Error in: " + Request.Url.ToString() +
  6.                           ". Error Message:" + objErr.Message.ToString();
  7.         String myUrl = Request.Url.ToString().ToUpper();
  8.  
  9.         if (myUrl.EndsWith("/ARTICLES")) Response.Redirect("/" + Request.QueryString);
  10.         if (myUrl.EndsWith("/BLOG")) Response.Redirect("/listBlogs.aspx" + Request.QueryString);
  11.         if (myUrl.EndsWith("/CONTACT")) Response.Redirect("/contactUs.aspx" + Request.QueryString);
  12.         if (myUrl.EndsWith("/LINKS")) Response.Redirect("/listLinks.aspx" + Request.QueryString);
  13.         if (myUrl.EndsWith("/SEARCH")) Response.Redirect("/search.aspx" + Request.QueryString);
  14.         if (myUrl.EndsWith("/BOOK")) Response.Redirect("/" + Request.QueryString);
  15.  
  16.         if (myUrl.EndsWith("/ARTICLES/AUTHORSLIST.ASPX")) Response.Redirect("/listAuthors.aspx" + Request.QueryString);
  17.         if (myUrl.Contains("/ARTICLES/READ.ASPX?")) Response.Redirect("/readArticle.aspx?" + Request.QueryString);
  18.         if (myUrl.Contains("/ARTICLES/PRINTABLE.ASPX?")) Response.Redirect("/printable.aspx?" + Request.QueryString);
  19.         if (myUrl.Contains("/ARTICLES/AUTHORS.ASPX?")) Response.Redirect("/bioAuthor.aspx?" + Request.QueryString);
  20.         if (myUrl.Contains("/BLOG/READ.ASPX?")) Response.Redirect("/readBlog.aspx?" + Request.QueryString);
  21.  
  22.         Response.Redirect("errorPage.aspx");
  23.  
  24.     }
global.asa:
Expand|Select|Wrap|Line Numbers
  1.         if (myUrl.Contains("/ARTICLES/READARTICLE.ASP?")) Response.Redirect("/readArticle.aspx" + Request.QueryString);
  2.         if (myUrl.Contains("/ARTICLES/PRINTABLE.ASP?")) Response.Redirect("/printable.aspx?" + Request.QueryString);
  3.         if (myUrl.Contains("/ARTICLES/AUTHORS.ASP?")) Response.Redirect("/bioAuthor.aspx?" + Request.QueryString);
  4.         if (myUrl.Contains("/BLOG/BLOGENTRY.ASP?")) Response.Redirect("/readBlog.aspx?" + Request.QueryString);
  5.  
  6.  
Aug 19 '10 #1
0 1350

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by D. Shane Fowlkes | last post: by
3 posts views Thread by hansiman | last post: by
4 posts views Thread by Ron Weldy | last post: by
1 post views Thread by teo | last post: by
3 posts views Thread by =?Utf-8?B?R3JlZw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.