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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:03:09+00:00 2026-05-19T02:03:09+00:00

Our old ASP.net site stored static images in a sub directory on the root

  • 0

Our old ASP.net site stored static images in a sub directory on the root called /images.

Our new ASP.net MVC site stores these images in the new layout of /Content/Images

I’ve changed all the pages in the site to cope with the new folder structure, but I’d like to set up Permanent Redirects from the old static images to the new location.

Our site is hosted, and I don’t have control over IIS, so what is the best approach to solve 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-19T02:03:10+00:00Added an answer on May 19, 2026 at 2:03 am

    I use the following code for my MVC 2 websites:

    // The legacy route class that exposes a RedirectActionName
    public class LegacyRoute : Route
    {
        public LegacyRoute(string url, string redirectActionName, IRouteHandler routeHandler)
            : base(url, routeHandler)
        {
            RedirectActionName = redirectActionName;
            Defaults = new RouteValueDictionary(new { controller = "Home", action = "Index"}); // is not actually called
        }
    
        public string RedirectActionName { get; set; }
    }
    
    // The legacy route handler, used for getting the HttpHandler for the request
    public class LegacyRouteHandler : MvcRouteHandler
    {
        protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            requestContext.HttpContext.Response.Write("success");
            return new LegacyHandler(requestContext);
        }
    }
    
    // The legacy HttpHandler that handles the request
    public class LegacyHandler : MvcHandler
    {
        public LegacyHandler(RequestContext requestContext) : base(requestContext)
        {
            requestContext.HttpContext.Response.Write("success");
            ProcessRequest(requestContext.HttpContext);
        }
    
        protected override void ProcessRequest(HttpContextBase httpContext)
        {
            string redirectActionName = ((LegacyRoute) RequestContext.RouteData.Route).RedirectActionName;
            var route = new Route(redirectActionName, ((LegacyRoute)RequestContext.RouteData.Route).Defaults, new MvcRouteHandler());
    
            // Copy all of the querystring parameters and put them within RouteContext.RouteData.Values
            var values = new Dictionary<string, object>();
            foreach (var s in RequestContext.RouteData.Values)
            {
                values.Add(s.Key, s.Value);
            }
            foreach (var s in httpContext.Request.QueryString.AllKeys)
            {
                values.Add(s, httpContext.Request.QueryString[s]);
            }
            var data = route.GetVirtualPath(RequestContext, new RouteValueDictionary(values));
    
            httpContext.Response.Status = "301 Moved Permanently";
            httpContext.Response.AppendHeader("Location", "/" + data.VirtualPath + "/");
            httpContext.Response.End();
        }
    }
    

    Then I simply add legacy routes to my route map:

    routes.Insert(13, new LegacyRoute("search", "search/{query}", new LegacyRouteHandler()));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are porting our old Webapp from WebForms to MVC Asp.net , I have
We are creating a new site using ASP.NET membership provider for user registration and
In our system most of the code is in an asp.net (2.0) web site,
In our (quite large and old) ASP.NET application we use a lot of pages
Im working on porting some old ALP user accounts to a new ASP.Net solution,
Very odd problem as this is working perfectly on our old Classic ASP site.
I'm currently trying to interface our new intranet (ASP-MVC) with the web front end
Our asp.net app is running on 10 web servers, after we deployed the new
We've recently hired a design/ui/accessibility guy to give our asp.net MVC app a coat
Our business is transitioning from an old asp system to a newer ASP.NET system,

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.