So if I have a URL such as mysite.com/user/1234/show which object can I use in the view that is displayed to get at the 1234 int in the URL above? For instance I want to have an action link that uses the user id again for the next controller action call such as mysite.com/user/1234/edit.
Thanks
You shouldn’t have to go directly to the URL for the data. Instead, add a parameter to your route and action. Your route could look something like
"{controller}/{id}/{action}"and your action something like:Then, in your view, use
Model.UserID.EDIT: This is initially more work than just doing a (dare I write it?)
in your view. However, the approach I have shown above is the preferred approach, since you will be leveraging the power of MVC’s routing and binding capabilities. If you want to change parameter name someday, you just need to fix your route and the action’s parameter name, as opposed to having to sort through all of your application searching for places where you pull values directly from the
Requestcollection.