Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 200141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:05:09+00:00 2026-05-11T17:05:09+00:00

I’ve replaced an old PHP web site with a new ASP.NET MVC web site.

  • 0

I’ve replaced an old PHP web site with a new ASP.NET MVC web site. The old page addresses no longer work. I want each to 301 (Moved Permanently) redirect to specific new addresses.

But, IIS 7 seems to intercept many such requests before they get to my application. I want to handle the error logging and redirections in the Application_Error() method of my Global.asax file rather than have IIS serve up generic error pages.

How must I modify IIS to allow this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:05:09+00:00Added an answer on May 11, 2026 at 5:05 pm

    I think MVC does not see this as an error (i.e. raises no exception), but rather it simply does not match any of the routes, and as such lets IIS handle the 404 as it normally would. To handle this in code I would add a wildcard route at the end of your routing list.

    Global.asax.vb…

    routes.MapRoute( _
        "FileNotFound", _
        "{*key}", _
        New With {.controller = "FileNotFound", _
                  .action = "Http404"} _
    )
    

    FileNotFoundController.vb…

    Function Http404(ByVal key As String) As ActionResult
        Dim RedirectId As Guid
        Select Case key
            Case "someold/path/andfile.php"
                RedirectId = New Guid("68215c26-0abe-4789-968e-0187683409b6")
            Case Else
                RedirectId = Guid.Empty
        End Select
        If Not RedirectId = Guid.Empty Then
            Response.StatusCode = Net.HttpStatusCode.MovedPermanently
            Response.RedirectLocation = Url.RouteUrl("SomeOtherRoute", New With {.id = RedirectId})
        Else
            Throw New Exception("Unable to resolve route.")
        End If
        Return Nothing
    End Function
    

    This will let you look at the intended URL and decide which target URL to redirect it to.

    Alternatively, you could implement a custom 404 handler page and set that in IIS directly. In the code of that page/controller you could look at the intended URL and redirect as neccessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.