Asp.net MVC: pass query string as string or separate parameters?

In asp.net MVC I have a search action in my controller and I'm trying to solve. If I have to pass the request to my repository as a string

public ActionResult Search(string query)
{
    return View(_repository.ListPeople(query));
}

or as separate parameters:

public ActionResult Search(string FirstName, string LastName, System.Nullable<byte> Education)
{
    return View(_repository.ListPeople(FirstName, LastName, Education));
}

Many of the examples I've seen on the Internet use the query string method, but it doesn't feel “safe” for me, although it’s a little easier to handle when you have a bunch of parameters to go through. Is there a general consensus on a better way to do this?

+3
source share
3 answers

. , , , .

+2

, . , , - . , , .

, , . , . , (, , ), - , , , .

+2

. . , - . . .

+1

Source: https://habr.com/ru/post/1713169/


All Articles