How do you read a parameter from the URL?
I am trying to use the login.aspx page in such a way that when a
user tries to access any given page, it will redirect them to the login screen
if they are not authenticated and after a successful authentication go back to
the page they were trying to access. My issue is that when I go to the page and
get redirected, I don’t go back to the page I came from. Here is a sample of
what my login.aspx page has for an URL:
http://localhost/Login.aspx?ReturnUrl=/OtherPage.aspx
As you can tell, ASP.Net is smart enough to include the return to
URL, however, how can I make use of that to redirect my users back to that page? Also, in general, how can you read a parameter in the URL query string?
Thanks!
The following code would address the issue. Note that you can read any Paramater by doing a QueryString from the Request. ReturnUrl is the one that pertains to this particular example:
if (Request.QueryString["ReturnUrl"] != null)
{
string ReturnUrl = Request.QueryString["ReturnUrl"].Trim();
//Navigate to the ReturnUrl
}
else
//Navigate to a specific home page
Love
Can we use Let's Encrypt, the free and open certificate authority?
Hola! gracias por la info, me sirvió el comando sacandole el nombre del server. En mi caso, fue una migración…
Yes 3rd option helped me too. I removed the WC key Values from config file then started working.
I know this is from 2014. But really, thank you!