3

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}) %>
1
  • Can you post the (HtmlHelper) method call you're using generate the url? Commented Nov 16, 2009 at 23:47

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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

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.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.