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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • user65
    New Member
    • May 2010
    • 23

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

    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:
    Code:
        void Application_Error(object sender, EventArgs e) 
        {
            // Code that runs when an unhandled error occurs
            Exception objErr = Server.GetLastError().GetBaseException();
            string err = "Error in: " + Request.Url.ToString() +
                              ". Error Message:" + objErr.Message.ToString();
            String myUrl = Request.Url.ToString().ToUpper();
    
            if (myUrl.EndsWith("/ARTICLES")) Response.Redirect("/" + Request.QueryString);
            if (myUrl.EndsWith("/BLOG")) Response.Redirect("/listBlogs.aspx" + Request.QueryString);
            if (myUrl.EndsWith("/CONTACT")) Response.Redirect("/contactUs.aspx" + Request.QueryString);
            if (myUrl.EndsWith("/LINKS")) Response.Redirect("/listLinks.aspx" + Request.QueryString);
            if (myUrl.EndsWith("/SEARCH")) Response.Redirect("/search.aspx" + Request.QueryString);
            if (myUrl.EndsWith("/BOOK")) Response.Redirect("/" + Request.QueryString);
    
            if (myUrl.EndsWith("/ARTICLES/AUTHORSLIST.ASPX")) Response.Redirect("/listAuthors.aspx" + Request.QueryString);
            if (myUrl.Contains("/ARTICLES/READ.ASPX?")) Response.Redirect("/readArticle.aspx?" + Request.QueryString);
            if (myUrl.Contains("/ARTICLES/PRINTABLE.ASPX?")) Response.Redirect("/printable.aspx?" + Request.QueryString);
            if (myUrl.Contains("/ARTICLES/AUTHORS.ASPX?")) Response.Redirect("/bioAuthor.aspx?" + Request.QueryString);
            if (myUrl.Contains("/BLOG/READ.ASPX?")) Response.Redirect("/readBlog.aspx?" + Request.QueryString);
            
            Response.Redirect("errorPage.aspx");
    
        }
    global.asa:
    Code:
            if (myUrl.Contains("/ARTICLES/READARTICLE.ASP?")) Response.Redirect("/readArticle.aspx" + Request.QueryString);
            if (myUrl.Contains("/ARTICLES/PRINTABLE.ASP?")) Response.Redirect("/printable.aspx?" + Request.QueryString);
            if (myUrl.Contains("/ARTICLES/AUTHORS.ASP?")) Response.Redirect("/bioAuthor.aspx?" + Request.QueryString);
            if (myUrl.Contains("/BLOG/BLOGENTRY.ASP?")) Response.Redirect("/readBlog.aspx?" + Request.QueryString);
Working...