views:

35

answers:

2

Hi,

I have switched from asp.net mvc 1.0 to 2.0

My actionlinks:

<%=Html.ActionLink("Add bla", "addbla", new { id = Model.Id })%>

now produce urls like this:

addbla/500

rather than:

addbla/?Id=5008

does this have to do with the routing:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });

            routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional }  // Parameter defaults
            );

How can I restore the old behaviour?

Thanks.

Christian

A: 

Try using lowercase id instead of mixed case. I haven't seen this problem in the one project I've transitioned, but I consistently use the lowercase id.

tvanfosson
I actually changed it to upper case Id from id. neither works. will update question
csetzkorn
A: 

You can restore the old behavior removing id from MapRoute

routes.MapRoute(
   "Default", // Route name
   "{controller}/{action}", // URL with parameters
   new { controller = "Home", action = "Index" }  // Parameter defaults
);
Caline
that's what I did see my comment above. I still do not understand why a url bla/33 results in an id being null in my controller.
csetzkorn
I didn´t see your comment, but my idea was to replace your MapRoute, instead of inserting it before.Replacing MapRoute, bla/33 won´t work because there is no controller bla and action 33. It will work only with bla?Id=33Inserting this MapRoute before the other one (more generic and with id) both url work in my tests.
Caline