views:

241

answers:

2

Hello Everyone,

I search and read all the questions i could find here and in google, and I can't seem to find the answer!

The Rout in questions is this:

routes.MapRoute("Admin - Change Password", "Admin/ResetPassword/{UserId}", New With {.controller = "Admin", .action = "ResetPassword", .UserId = ""})

The Url It Generates is: /Admin/UserAdmin

which is the page the url.action is on. No idea if that matters or not.

When I used the route debugger it showed the Url I expect it to generate as matching the URL i typed in my address bar.

True Admin/ResetPassword/{UserId} controller = Admin, action = ResetPassword, userId =

The only other routes it matched were:

True {controller}/{action}/{id} controller = Home, action = Index, id =

True {*catchall} (null)

The {controller}/{action}/{id} route is the last one, so it shouldn't be interfering.

Any Ideas?

EDIT: the code of the helper:

<%Url.Action("ResetPassword", "Admin", new with {.UserId= u.userId}) %>
A: 

So I assume the problem is that you aren't getting directed to the view you expected when you run the application?

What version of IIS are you using? If you are using XP / IIS 5.1, did you make sure to add a wildcard mapping? This is a common gotcha with IIS 5.1.

You can refer to the link here.

dcp
I don't think that is the problem. I have lots of other routes mapped that work correctly. It's just this one specific one that is misbehaving.
Patricia
+2  A: 

Don't use Action/ActionLink to generate a URI for a named route. Use RouteLink/RouteUrl, instead. It's faster, and it never fails to find the route you intend. Full explanation here.

Craig Stuntz
Thanks. Using this solved the problem!<%=Url.RouteUrl("Admin - Change Password", New With {.UserId = u.UserId})%>">
Patricia