I have a controller that looks like this:
public ActionResult Sold()
{
using (WipDBEntities db = new WipDBEntities())
{
ViewData.Model = db.GetSummaryProiect("Test").ToList();
return View();
}
}
This is working fine except that when i try to get the parameter fr开发者_StackOverflow社区om the url my view is empty
public ActionResult Sold(string PrjCode)
{
using (WipDBEntities db = new WipDBEntities())
{
ViewData.Model = db.GetSummaryProiect(PrjCode).ToList();
return View();
}
}
I'm new to mvc so probably i'm doing something wrong, can you help me ?
EDIT
I have a route to handle this
routes.MapRoute(
"Componente", // Route name
"Componente/Sold/{PrjCode}", // URL with parameters
new { controller = "Componente", action = "Sold", PrjCode= "" } // Parameter defaults
);
The url looks like [hostname]/Componente/Sold/Test
Where are you expecting that value to come from? If you are using the default route of {controller}/{action}/{id}
, and your value is in the {id}
placeholder then the parameter name on your action method needs to be id
.
精彩评论