views:

945

answers:

2

Hi,

I need your advice regarding migration. I want to migrate existing project to ASP.NET MVC and I can figure out the proccess except of url rewriting issue:

for example how can I make following route:

http://www.eireads.com/ireland/mayo/cars-3/1263-used-cars-citroen-c5-for-sale.aspx

Or maybe I could somehow keep supporting legacy routes.

Please help

A: 

I think you should really re-write your question and try to detail exactly what you are attempting to accomplish here.

If you are asking how to migrate an existing WebForm project into ASP.NET MVC keeping the same URL rewrite, the answer is; not easily. The models are too different.

Yet, you mention "routes" in the end, which make me think you are speaking like those of the System.Web.Routing namespace. So are you dealing with an existing MVC app and want it too look like that URL path? I can't tell. I am confused.

Ian Patrick Hughes
+2  A: 

I think that migrating a web forms applicaiton to MVC is going to be very hard unless you have a clear seperation of concerns in your current applicaiton. If you have followed a design pattern like MVP then it might be easier, but if not then much of your business logic is likey going to have to be moved to controller classes and much of it re-written.

I would start by extracting your model, this should be fairly easy, then identifying your controllers and actions and seeing how much code you can re-use. At this point you should be able to discern whether or not you can migrate or if you'll be better off re-writing portions of your applicaiton.

Default URL patterns in ASP.NET MVC are http(s)://(appdomain)/(controller)/(action)/(par/ame/ters)

So your url above should fit into that pattern. You can change the pattern to account for other things (like namespace for example). Your URL pattern might be:

http://www.eireads.com/cars/used/ireland/mayo/citreon

where ireland, mayo and citreon are the in put parameters.

Odd