Accessing route values in view Mvc.net


Accessing route values in view Mvc.net



i m using default route of mvc2 like {controller}/{action}/{id}. I want to access that id field in my view. How can i do that without using TempData and ViewData?

If I have a url like http://server-name/home/edit/14 I need the value "14" in the view.


Is this code business logic or presentation logic?

1:

Sending collection of items in ASP.NET MVC
You must access route data using the ViewContext property:. ASP.NET MVC forces an AJAX request be redirected to the login page when the FormsLogin session is no longer active
<%= ViewContext.RouteData.Values["id"] %> 
How to make a default editor template for enums?

68 out of 100 based on 73 user ratings 828 reviews

#