开发者

Passing variable from view to the controller without query string

开发者 https://www.devze.com 2023-03-27 03:46 出处:网络
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

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:

  1. Create a form on the view and name the fields in which you are interested.
  2. Create an action on the controller whose parameters match those names.
  3. Add the [AcceptVerbs(HttpVerbs.Post)] attribute to the action.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号