If i click the back button in browser i got some problem.
i click the login and redirected to another page.after that i click the back btn its navigated to login page.but it didnt clear my session value login=true.still that user in login stage but that login page looking normal that is it contains menu.. login..signup. if i click any other page it contains menu ..logout.

i used some server side and client side code but there is no improvement.

If i click the back btn,i dont want any navigation.its in current page or refresh the current page.Is there any other way to achieve this result. or Is there any other way for proper navigation

two ways to do this:

Put in your sub prerender ... end sub location one of these two choices.

Session.Abandon() which ends all session variables

or

If Session("login") = True Then response.redirect("correctpage.aspx")

I tried this one in page prerender
If Session("login") = True Then response.redirect("correctpage.aspx")
but page cannot be displayed at first time load. tell me detail.

The stages of loading a page with subs follows:

Page Initialization (Page_Init)
Page Loading (Page_Load)
Page Pre Rendering Phase (Page_PreRender)
Page Rendering (Page_Render) (This is rarely used, as the page is being rendered to the client)
Page Unloading (Page_UnLoad)

For this, you should put it in Page_init. It is the first thing being called and you don't have to waste server load and time building the page and shooting all functions/subs just to find out it needs to redirect. If you have the information before the page loads, then use it!

When a user logs on, set the : Session("login") = "True"

Then on page_init, check for: if Session("login") = "True" then response.redirect("page.aspx")

PreRender is the last stage before the client sees the page. This is when you want to do stuff to the web page that you had to wait for page_load to shoot.

Sorry I couldnt get.Once again i will explain my need.
If session[login]=true, At that time i click the back btn in my web page,its stay in that page no need navigation .if its not possible just refersh the page.
If session value not equal to true there is normal navigation.

for example now i an in home page i click the contact page in menu,redirect to that page.there is no login=true.i click the back btn.naviagted to home page.k

Next i used my login details in home page and redirected to one X page after login.In that X page i click the contact in menu.but didnt load and redirect to contact page from X page.I am using this in Page_Init of contact page

     {
        if ((string)Session["login"] == "true")
        {
            Response.Redirect("conta.aspx", false);
        }

Is it correct ?
In this place my actual need is redirect to contact page in that page i click back btn.its stay in same page.here didnt load contact page. what to do.
and also ont thing In some pages i want to navigate use back btn if login=true
I want to use this init fun in some of the pages particluarly after the login page.coz after login they use only logout.thats only clear all session variable .if use back btn redirect to login session values not clear.

Do u understand my pbm?

Is there any other way to clear session values particularly after the login page back btn use.
Till that navigation is no problem in site.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Hi I got one solution.Please check it,
After Login bt click its not directly redirect to X page .Now i am using another one page between login and X page just for redirection.its solved my problem.is it K.
So i click in back btn in X page its just refresh the X page.

Hi I got one solutionPlease chech it,
After Login bt click its not directly redirect to X page .Now i am using another one page between login and X page just for redirection.its solved my problem.is it.
So i click the back btn in X page its just refresh the X page.

Hi I got one solution.Please check it,
After Login bt click its not directly redirect to X page .Now i am using another one page between login and X page just for redirection.its solved my problem.is it K.
So i click the back btn in X page its just refresh the X page.

that sounds fine, but you can use the same code on the redirect page on the login page. There should be no reason you cannot. However, if it works, it works!

<script type="text/javascript" language="javascript">
javascript:window.history.forward(1);
</script>
I am using code in X page.So i couldnt move to previous of X page. .

This article has been dead for over six months. Start a new discussion instead.