View Full Version : asp.net url variables to populate form fields and/or auto submit

11-12-2010, 05:47 PM
I have a shortcut on my desktop to a login page for a website I use quite often. Every time I go there I have to reenter my user name and password.

The desktop URL shortcut I have is

Iíve tried adding the following changes

But this doesnít auto populate the fields on the website when it loads. Is there something special I need to do so the webpage will fill in the fields on the form?

Also bonus if I could just auto submit to login so I donít need the page to load and have me click ďloginĒ but I donít think thatís possibleÖ or is it?
Any help is greatly appreciated.

11-14-2010, 02:36 AM
Your login page is not set-up to parse the values (your password and username) in your URL, so that is why you can't just send them via your URL and retrieve them via a GET request. To do so, you'll need to add code which uses the Request.Querystring object to retrieve your username and password values from the URL, something like:

string username = Request.Querystring["username"];
string password = Request.Querystring["password"];

This stores the Request objects into string variables and then you can use them however you want, in your case, pass them to the login control or whatever code you are using for the login validation.

You'll want to put the code to the get the Request objects, your username and password values from the url, in your Page_Load event in your aspx page (ie. in your login.aspx.cs page) so it'll grab them once the page is loaded. This is important.

Again, hard to answer your question without knowing your login script and which version of ASP.NET you are using, or which language (C# or VB) you are using.

Search for "Request.Querystring", "ASP.NET Page_Load" event and "ASP.NET Login Control" and you should find info on what to do.