back in history on aspx page

  • Thread starter Thread starter Lubo¹ ©lapák
  • Start date Start date
L

Lubo¹ ©lapák

Hi,
I have a login page and after click on button Login I check username and
password and if it is correct, i want load page, which was there before
Login page. How can I do it? In javascript it is simply

<script language="javascript">window.history.back();</script>

but How can I do it in C# code?

Please help. Thanks Lubos
 
How do you go to the login page? I mean... if I land of secretpage.aspx, how
do you validate the login?

Are you using web.config configuration or FormsAuthentication on each secret
page?
 
I don't use web.config, because i don't know how to use it, i have
Login.aspx and when i go to secret page, it is redirect to Login page, where
i validate login information from database. So I need after login redirect
back on secret page.
 
How does secret page know whether you are logged in or not is what I want to
know...

Ok.. you can do the following:

1. Login.aspx
-> When you jump of the login page, do a:

// First time a user is redirected to the page
if(!IsPostBack)
ViewState["referer"] = Request.ServerVariables["HTTP_REFERER"];
else
// If user is validated, redirect him back.
if(ValidateUser(username, password))
Response.Redirect((string)ViewState["referer"]);
 
Hi,


It could be as easy as sending the referer page as a parameter:
you go to secretpage.aspx in the page_load do a check to see if the user is
logged, if not do a redirect to login.aspx?gonext=secretpage.aspx

in this way to know where to go after a succesful logon, you just do a
redirect pointed with the parameter.

cheers,
 
If you are using ASP.NET forms authentication, the safest way to
redirect is with FormsAuthentication.RedirectFromLoginPage.
 
Scott Allen said:
If you are using ASP.NET forms authentication, the safest way to
redirect is with FormsAuthentication.RedirectFromLoginPage.

That will require web.config modification... loginUrl= etc.

Lubos mentioned that he's not using web.config. Otherwise that's the
cleanest bet.


--

Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.org
-----------------------------------
 
I think it would be easier for him to learn how to use web.config then
reimplement forms based authentication with his own code.
 
Back
Top