0
我有以下控制措施:查询字符串不会映射到action videmode?
public ActionResult List(ListPostViewModel data)
{
return View(data);
}
视图模型看起来是这样的:
public class ListPostViewModel
{
public ListPostViewModel()
{
PLS = new PostListSettings();
}
public PostListSettings PLS;
}
这是视图模型的另一部分:
public class PostListSettings
{
public PostListSettings()
{
P = 1;
CP = int.Parse(ConfigurationManager.AppSettings["AmountOfPostsPerPage"].ToString());
}
/// <summary>
/// Amount of ads on one page
/// </summary>
public int CP { get; set; }
/// <summary>
/// CurrentPage
/// </summary>
public int P { get; set; }
}
在以前的项目中,我可以发送一个这样的URL:http://MyComputer/?PLS.P=2
并获得ListPostViewModel.PLS.P设置为2,但它不能在我的新ASP.NET MVC 4解决方案中工作?为什么?
我唯一的溃败是默认的一个:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Post", action = "List", id = UrlParameter.Optional }
);