Search code examples
asp.netasp-classicrequest.querystring

Request.QueryString doesn't get the input names from html form


I need to take the username, email and password a user enters in an html form (in index.aspx) and use it in an asp.net code in another page (register.aspx in a folder called 'u').

This is the form:

<form action="u/register.aspx" method="post" id="regForm">
            <input type="text" name="fname" id="fname" placeholder="Full Name (Optional)" maxlength="16" />
            <input type="text" name="uname" id="uname" placeholder="Username" maxlength="16" />
            <input type="email" name="email" id="email" placeholder="Email Address" maxlength="32" />
            <input type="password" name="pwd" id="pwd" placeholder="Password" maxlength="16" />
            <input type="password" name="repwd" id="repwd" placeholder="Repeat Password" maxlength="16" />

            <input type="submit" value="Sign Up" id="signup" />
</form>

But, when I'm using Request.QueryString["fname"] for example, it doesn't take 'fname' from the form, it just takes a null.

What can I do to solve this? Is there a different method I can use to achieve the wanted result?

Thanks a lot!


Solution

  • You are doing it wrong. Request.QueryString contains information related to data added after ? in the URL (ex. http://www.contoso.com?mydata=1&param2=yy).

    You have to use Request.Form to access "POST" data.