Search code examples
htmlasp.net-mvcform-submit

Hide form input fields from URL


I've got a login form with two input fields: username and password.

<form method="get" action="../Main/Index">
    <p>
        <input type="text" name="username" value="" placeholder="username" maxlength="30"></p>
    <p>
        <input type="password" name="password" value="" placeholder="password" maxlength="25"></p>

    <p class="submit">
        <input type="submit" name="commit" value="Enter">
    </p>

</form>

Once the user submits the form, his username and password are shown in the browser's URL textbox, something like this:

http://localhost:53997/Main/Index?username=zm&password=123456789&commit=Enter

I don't want his username and password to be on display.

How can I do this?


Solution

  • the problem is that youre using form method = "get" when you should be using form method = "post" instead.

    this explains it:

    http://msdn.microsoft.com/en-us/library/ee784233(v=cs.20).aspx