Passing variable from view to the controller without query string
I'm fairly sure I'm missing something very practical but I'm floundering at finding it online.
How do you pass information from the view to the controller without 开发者_开发知识库using URL items (query strings, /variable/ etc?
The easiest scenario I can think that surely must have an example is a simple set of login credentials handed to a controller. Naturally you wouldn't want the username / password to be viewable in the URL.
You can POST data to the controller, so that it doesn't appear in the URL. See this blog post for details.
The basic steps are:
- Create a form on the view and name the fields in which you are interested.
- Create an action on the controller whose parameters match those names.
- Add the
[AcceptVerbs(HttpVerbs.Post)]
attribute to the action.
精彩评论