Reputation: 171
hi i have a weird problem and here we go:
i am redirecting using this command :
return RedirectToAction("ViewMessage", "Account", new {id = model.MessageId});
but in ViewMessage action when i try to get id, its null ?!?!?!?!??
string strMessageId = RouteData.Values["id"] as string;
i have done this code in lots of places and it works fine but i dont know what is going on here.... :(
i know i can use TempData but i dont want to :)
Upvotes: 1
Views: 2099
Reputation: 43
Check your routing configuration. If your action parameter name is "id" then your routing url pattern should be {controller}/{action}/{id}.
Upvotes: 0
Reputation: 1585
Actually the way you did worked for me still Try This
return RedirectToAction("ViewMessage",new RouteValueDictionary(new {controller="Account",action="ViewMessage", id = model.MessageId }));
Upvotes: 1
Reputation: 1
Try accessing the route value using the View Context
ViewContext.RequestContext.RouteData.Values("id")
Upvotes: 0