views:

38

answers:

2

I've been reading up on MVC2 which came in VS2010 and it sounds pretty interesting. I'm actually in the middle of a large multi-tenant application project, and have just started coding the UI. I'm considering changing to MVC as I'm not that far along at this point. I have some questions about the Routing capabilities, namely are they required to use MVC or can I more or less ignore Routing? Or do I have to setup a default routing record that will make things work like standard ASPX (as far as routing alone is concerned)?

The reason why I don't want to use Routing is because I've already defined a custom URL 'rewrite' mechanism of my own (which fires on session_start). In addition, I'm using jquery and opens-standards for the entire UI, and MVC's aspx overhead-free approach seems like a better fit based on how I've already started to build the application (I am not using viewstate at all, for example).

I guess my big concern is whether the routing can be ignored, of if I will have to re-implement my custom URL rewriting to work with MVC, and if that's the case, how would I do that? As a new Routing routine, or stick with the session_start (if that's even possible?).

Lastly, I don't want to use anything even remotely 'intelligent/readable' for the url - for a site like StackOverflow, the readability of the URL is a positive, but the opposite is true if it's not a public website like this one. In fact, it would seem to me that the more friendly MVC routing URL (which indirectly show method names) could pose a security risk on a private, non-public website app like I'm developing.

For all these reasons I would love to use the lightweight aspects of MVC but skip the Routing entirely - is this possible?

A: 

You could make it work without routing, but you would have to rebuild a lot of the framework and pretty much build your own routing engine. That wouldn't really make any sense as Microsoft already provide you with a great routing framework. All your url rewriting rules could easily be implemented using the routing framework anyway. You don't have to have the action name of the controller name in the url if you use the routing framework. As long as you can tell what action should be executed from the raw url it could be implemented.

My advice would be to read up on the routing framework and learn how it works. I'm pretty sure you will not regret it.

Mattias Jakobsson
Thanks, yeah the more I read/play with this the more I like it but also realize it's probably not ideal for this particular project. I think I will use this for another project that doesn't have any security and/or URL rewriting going on. In fact the other project would benefit from a nice, clean URL scheme like this.
evo_9
@evo_9, If you need URL rewriting then using asp.net mvc is a big plus (very easy to write your rules). And I can't see the security risks you are talking about. But asp.net mvc might not fit every solution, so you might have other reasons not to use it.
Mattias Jakobsson
A: 

Don't bypass routing

Routing is imperative part of Asp.net MVC and ignoring it will cause more or less trouble. You could get by by using ISS7 URL Rewriting module, but it will only work if your requests have a certain format, otherwise you will end up writing rewrites for every single request that is used in your app.

The good thing is that routing is nothing you should be afraid and is quite simple to understand as long as you don't start havind some complex routing rules. Then you will delve even deeper into it and probably love it even more.

Robert Koritnik