Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 03, 2012 03:18 AM by ignatandrei
Member
105 Points
175 Posts
May 02, 2012 11:21 PM|LINK
Hello,
I have a directory called specials that is currently in use, but I want to convert that to
a MVC 2 application I already wrote. But I want to make sure everyone finds it so i want to
use the old application default.asp to redirect to the new one.
EX from: http://localhost/default.asp to
EX http://localhost/
i can put a simple 302 redirect in the default.asp file, but it is forbidden when i call it
here is my route table but i am not sure how to accomplish this. As you will see below I am useing a Null route,
because localhost will become specials as an application folder in another website so example or real url would be
dummyurl.com/specials/ for the mvc application hope i am explaining this well enough
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{Path}/{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{Path}/{resource}.jpg/{*pathInfo}"); routes.IgnoreRoute("{Path}/{resource}.gif/{*pathInfo}"); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{resource}.jpg/{*pathInfo}"); routes.IgnoreRoute("{resource}.gif/{*pathInfo}"); routes.IgnoreRoute("{resource}.asp/{*pathInfo}"); routes.MapRoute( null, "{type}/{SortRange}", // URL with parameters new { controller = "Specials", action = "Index", type = UrlParameter.Optional, SortRange = UrlParameter.Optional, page = UrlParameter.Optional } // Parameter defaults ); }
All-Star
27516 Points
4897 Posts
MVP
May 02, 2012 11:29 PM|LINK
Consider doing this at the IIS level with the URL rewrite module.
May 02, 2012 11:33 PM|LINK
is that the only way to learn a whole new thing to me?
134871 Points
21618 Posts
Moderator
May 03, 2012 03:18 AM|LINK
By default, MVC does not route existing files.( can be changed)
So, if you want to route
Tdar EX from: http://localhost/default.asp to EX http://localhost/
1. delete the .asp file
2. register the .asp extension to be processed by asp.net engine
3. register a route that ends in .asp
routes.MapRoute( "New ROUTE FOR ASP", "{type}/{SortRange}.asp", // URL with parameters new { controller = "Specials", action = "Index", type = UrlParameter.Optional, SortRange = UrlParameter.Optional, page = UrlParameter.Optional } // Parameter defaults );
Tdar
Member
105 Points
175 Posts
MVC and .asp pages take over directory
May 02, 2012 11:21 PM|LINK
Hello,
I have a directory called specials that is currently in use, but I want to convert that toa MVC 2 application I already wrote. But I want to make sure everyone finds it so i want touse the old application default.asp to redirect to the new one.EX from: http://localhost/default.asp toEX http://localhost/here is my route table but i am not sure how to accomplish this. As you will see below I am useing a Null route,because localhost will become specials as an application folder in another website so example or real url would bedummyurl.com/specials/ for the mvc application hope i am explaining this well enoughpublic static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{Path}/{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{Path}/{resource}.jpg/{*pathInfo}"); routes.IgnoreRoute("{Path}/{resource}.gif/{*pathInfo}"); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{resource}.jpg/{*pathInfo}"); routes.IgnoreRoute("{resource}.gif/{*pathInfo}"); routes.IgnoreRoute("{resource}.asp/{*pathInfo}"); routes.MapRoute( null, "{type}/{SortRange}", // URL with parameters new { controller = "Specials", action = "Index", type = UrlParameter.Optional, SortRange = UrlParameter.Optional, page = UrlParameter.Optional } // Parameter defaults ); }BrockAllen
All-Star
27516 Points
4897 Posts
MVP
Re: MVC and .asp pages take over directory
May 02, 2012 11:29 PM|LINK
Consider doing this at the IIS level with the URL rewrite module.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
Tdar
Member
105 Points
175 Posts
Re: MVC and .asp pages take over directory
May 02, 2012 11:33 PM|LINK
is that the only way to learn a whole new thing to me?
ignatandrei
All-Star
134871 Points
21618 Posts
Moderator
MVP
Re: MVC and .asp pages take over directory
May 03, 2012 03:18 AM|LINK
By default, MVC does not route existing files.( can be changed)
So, if you want to route
1. delete the .asp file
2. register the .asp extension to be processed by asp.net engine
3. register a route that ends in .asp
routes.MapRoute( "New ROUTE FOR ASP", "{type}/{SortRange}.asp", // URL with parameters new { controller = "Specials", action = "Index", type = UrlParameter.Optional, SortRange = UrlParameter.Optional, page = UrlParameter.Optional } // Parameter defaults );