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 }
);