Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net Mvc 3 Url.Action method uses parameter values from previous request

When Urls are autogenerated using the Url.Action helper, if a page contains a line similar to

@Url.Action("Edit","Student")

is expected to generate a url like domain/student/edit and its working as expected. But if the requested url contains some parameters, like domain/student/edit/210, the above code uses these parameters from the previous request and generates something similar even though I've not provided any such parameter to the Action method.

In short, if the requested url contains any parameters, any auto generated links of the page (served for that request) will include those parameters as well no matter if I specify them or not in the Url.Action method.

What's going wrong?

like image 456
Mat J Avatar asked Jul 14 '11 08:07

Mat J


1 Answers

Use Darin's answer from this similar question.

@Url.Action("Edit","Student", new { ID = "" })
like image 184
WEFX Avatar answered Oct 28 '22 10:10

WEFX