我有以下控制动作:
public ActionResult List(ListPostViewModel data)
{
return View(data);
}
ViewModel 看起来像这样:
public class ListPostViewModel
{
public ListPostViewModel()
{
PLS = new PostListSettings();
}
public PostListSettings PLS;
}
这是 ViewModel 的另一部分:
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 }
);