Help with route rewrite in asp.net mvc

Posted by NachoF on Stack Overflow See other posts from Stack Overflow or by NachoF
Published on 2009-09-09T16:33:59Z Indexed on 2010/04/14 2:03 UTC
Read the original article Hit count: 527

Filed under:
|
|

Im having a really hard time understanding routing.

Please help me with this problem.

Each of my controllers have these three actions right now

Users have Index, Create and Edit

Locations have Index, Create and Edit

Companies have Index, Create and Edit

The thing is, it all gets done through ajax.

I have jquery ui tabs with two tabs for each, Create and Edit So the Index method is always the one that gets called for action links. and inside this main view is that you can call(by clicking on the tab icon) the other methods that return an ajax view that gets output into the jqeury tab (I hope thats clear)

I have a sidebar with links to the controllers. and to specific methods of these controllers. The wanted behavior is that it should actually go into the Index Method and then with some logic autoload the wanted tab.

It all works just fine right now. But my urls are horrible. To get to the create method for Users I have to go this url

http://localhost/Users/Index/1

http://localhost/Users/Index/2

I want the behavior of these links to be remapped to these links

http://localhost/Users/Create

http://localhost/Users/Edit

So even though it seems as if you are calling the Create method of the controller you are actualling always calling the Index Method.... (I know how to transform Create into "1" and Edit into two, so dont worry about that part

Hope thats clear. Thanks in advance

Edit:

Just realized that this might not be possible cause then when I actually need to call the methods (with ajax) it wont know what to do.... am I correct?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about mvc