Reputation: 5266
I am calling a action with the parameter value. But it is not assigning parameter value to action method parameter.
public ActionResult UserDetail(long? userId)
{
}
localhost/Admin/UserDetail/10 --> 10 is not passed to userId
But
localhost/Admin/UserDetail/?userId=10 --> This works
What causes the first url not working? Any help?
Update:
tried this in global.asax still not working
routes.MapRoute("ExistSiteUser",
"UserDetail/{userId}",
new
{
controller = "Admin",
action = "UserDetail",
// nothing optional
}
);
routes.MapRoute("NewSiteUser",
"UserDetail",
new
{
controller = "Admin",
action = "UserDetail",
userId = UrlParameter.Optional
}
);
Upvotes: 1
Views: 1570
Reputation: 3281
Replace this userID to id :-
public ActionResult UserDetail(long? id)
{
}
Upvotes: 3
Reputation: 1527
change the parameter name to 'id' instead of 'userid' and then try....it should work then
public ActionResult UserDetail(long? id)
{
}
Upvotes: 3