would not like to show session variable

asp.net Mauritius
  • 14 years ago

    Hi all,

    Actually yesterday i had a meeting with my project supervisor at the university. He requested me trhat the session variable that should be appear upward (Address Browser) should be terminated so that another user does not take the url in the browser and check the page. That is if another person takes http://www.developerfusion.co.uk/forums/AddPost.aspx?ForumID=9 and paste it in the object browser and try to access this page then the system will redirect him to the main or the index page. and the person will not be able to access to that page directly.  Please note that i am making my project using Vb language. Thanks.

  • 14 years ago

    Hi Vinay,

    If you want to pass Session variable to other page. Dont pass it using Query String.

    When you redirect to other page, session variable can be accessible using the same name of Previous Page.

    And for security reason:

    Check in all page, in Page_load event, If session variable has no value then redirect it to the default page.

     

    I hope this will solve your problem.

    Regards,

    Chital

  • 14 years ago

    Hi Chital,

    Perhaps I haven't explain myself clearly. Consider a web program and we will have different page in it. We can view an individual page through the address browser.for e.g:http://www.developerfusion.co.uk/forums/AddPost.aspx?ForumID=9. Now i'll be in need for a way that if i'll paste this link on my address browser the user will be redirect to the default.aspx page. Please help how can i do it with an example if possible. please!!!

  • 14 years ago

    Hi

    do check for the security variables such as username,sessionid  etc..

    so that once those variables are false..

    just redirect them to the default page.aspx

    hope this will give u some idea

    With Thanks.,

    R.Chezhian.,

  • 14 years ago

    Hi Vinay,

    Sorry for posting answer late but was busy with work.

    Yes, For eg: Suppose you have two web forms 1) login.aspx 2) home.aspx

    In LOGIN.ASPX

    when User is authorised to access the system its username is passed to home page.

    Session.Add("sesUsername","txtUsername.Text")

    Response.Redirect("Home.aspx")

    In HOME.ASPX

       In Page_Load event() write following code

          If Not IsPostBack then

                if Session("sesUsername")<>"" then

                   ' Code whatever you want to write

                else

                   Response.Redirect("login.aspx")

                end if

          End If

     

    So, in short, the session variables which you pass from one page to another, then check the value of session variable to the other page(here HOME.ASPX)  in Page_Load event. Check for the same in each and every page of the system.

     

    I hope I can able to describe you.

    If No, then I will send you some code.

    Regards,

    Chital Panchal

     

     

  • 14 years ago

    Hi all,

    Thanks a lot I've beenable to solve the problem during the wee ends.

     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.”