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 6994557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:54:28+00:00 2026-05-27T19:54:28+00:00

I have an asp.net mvc3 website. It replaced an older php website. Many people

  • 0

I have an asp.net mvc3 website. It replaced an older php website. Many people have parts of the site bookmarked in reference to the .php locations and I would like to add those back into the asp.net site as simple forwards to the new location. So mysite/product.php would redirect to mysite/usermap/product.cshtml for example. When I insert the product.php into the directory and use an anchor href to it, I am prompted to open it with a certain program or save it. Any ideas?

  • 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-27T19:54:29+00:00Added an answer on May 27, 2026 at 7:54 pm

    You could make a small redirection controller, and add a route to match something like mysite/{id}.php.

    Then in that controller

    public ActionResult Index(string id)
    {
        return RedirectToActionPermanent("Product", "YourExistingController", id);
    }
    

    edit

    In your global.asax.cs file

    public void RegisterRoutes(RouteCollection routes)
    {
        // you likely already have this line
         routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
        // assuming you have a route like this for your existing controllers.
        // I prefixed this route with "mysite/usermap" because you use that in your example in the question
        routes.MapRoute(
            "Default",
            "mysite/usermap/{controller}/{action}/{id}",
            new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
    
        // route to match old urls
        routes.MapRoute(
            "OldUrls",
            "mysite/{oldpath}.php",
            new { Controller = "OldPathRedirection", action = "PerformRedirection", oldpath = "" }
        );
    }
    

    Then you would define an OldPathRedirectionController (Controllers/OldPathRedirectionController.cs most likely)

    public class OldPathRedirectionController : Controller
    {
        // probably shouldn't just have this hard coded here for production use.
        // maps product.php -> ProductController, someotherfile.php -> HomeController.
        private Dictionary<string, string> controllerMap = new Dictionary<string, string>()
        {
            { "product", "Product" },
            { "someotherfile", "Home" }
        };
    
        // This will just call the Index action on the found controller.
        public ActionResult PerformRedirection(string oldpath)
        {
            if (!string.IsNullOrEmpty(oldpath) && controllerMap.ContainsKey(oldpath))
            {
                return RedirectToActionPermanent("Index", controllerMap[oldpath]);
            }
            else
            {
                // this is an error state. oldpath wasn't in our map of old php files to new controllers
                return HttpNotFoundResult();
            }
        }
    }
    

    I cleaned that up a little from the original recommendation. That hopefully should be enough to get you started! Obvious changes are to not hardcode the map of php filenames to mvc controllers, and perhaps altering the route to allow extra params if you require that.

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

Sidebar

Related Questions

I have a website (ASP.NET MVC3) that runs on IIS 7. From this website,
I am currently working on an ASP.NET MVC3 website. I have a simple authentication
I hope that title is clear enough. I have 2 projects, MyProject.Website (ASP.NET MVC3
I have a website developed using ASP.NET MVC3. I now want to expose a
I'm building an ASP.NET MVC3 website. I have some javascript in my .cshtml file:
I have an asp.net-mvc3 website using nhibernate and SQL server. I have 2 web
We have a ASP.net MVC 3 website.We had to store many values in hidden
I am creating website (football, soccer) in ASP.NET MVC3 and I want have users
I have an ASP.NET MVC3 website with custom authentication (i.e. <authentication mode=None / >).
I have an asp.net mvc3 website, I need to update the database periodically, for

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.