From inside a viewpage, how can I reference the id from the url /controller/action/id without getting this data from the model?
From inside a viewpage, how can I reference the id from the url /controller/action/id
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can try the viewContext :
You still could get it via ViewData[“id”], if you put it inside viewdata in the controller, but if you do this, you might as well put it in the model.
You really should get it from the model, as previous options seems like a code smell to me.