在asp.net MVC我有我的控制器中的搜索行动,我试图决定我是否应该通过查询到我的仓库作为一个字符串asp.net MVC:将查询字符串作为字符串或单个参数传递?
public ActionResult Search(string query)
{
return View(_repository.ListPeople(query));
}
或作为单独的参数:
public ActionResult Search(string FirstName, string LastName, System.Nullable<byte> Education)
{
return View(_repository.ListPeople(FirstName, LastName, Education));
}
我在网上看到的很多例子都使用查询字符串方法,但对我来说它并不感觉“安全”,尽管当你有一堆参数传入时它会更容易处理。关于更好的方法来达成共识?
这似乎是最干净的方法,我在别处使用模型绑定我不太确定为什么我不认为在这种情况下使用它。谢谢! – 2009-07-21 17:19:33