1

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.

0

1 Answer 1

3

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.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.