0

My program directs users to a webpage with their username and password. E.g. http://example.html?username=username&password=password.

Now I created another page in asp.net and I want some code on example.html to redirect the link to http://example.aspx?username=username&password=password.

So what i want is to get the URI from the first url and direct it to the new url by appending the URI.

Any suggestions?

Dr. Mian
  • 3,334
  • 10
  • 45
  • 69

2 Answers2

1

You can grab the querystring in its entirety via

window.location.search

See this with more about that. Using this, you can extract the parameters, append them to a new URL, and render the link, or set

window.location = "example.aspx" + window.location.search

I believe search comes with "?", but I could be wrong. I assume this is an exmaple; note it's not a good practice to pass the password through a querystring as clear text, especially if you are not using HTTPS. It's generally advisable to do a POST operation, not a GET operation with querystring, when it comes to sensitive information.

Community
  • 1
  • 1
Brian Mains
  • 50,520
  • 35
  • 148
  • 257
0

Use window.location.search to get everything after "?". Then you can just direct the new aspx page using this java script line.

window.location = "example.aspx" + window.location.search
yurmont
  • 11
  • 2