locked
If any one Knows Real time Example of Application and Session Management in Simple Manner RRS feed

  • Question

  • User-389434962 posted

    Hello my name is Santosh kumar,

          Actually i complete M.S.Net course 2 days ago but I have an Idea but i don't Know how to work with in Real time 

                 Finally if you Know any simple Examples about this Two Toppiics Could you please Send me

    Friday, October 31, 2014 2:14 PM

Answers

  • User281315223 posted

    The Session is not going to be visible via the client unless you explicitly output it to the client. So if you created two Session values as you mentioned and stored the UserName and Age within them as follows :

    // Store these two values in the Session
    Session["Username"] = "Rion";
    Session["Age"] = "13";

    There is no way for a user to access this information unless you expose it yourself. They will not be able to see it by viewing the source or digging around using the Developer Tools (F12) within their browser. If you did actually need to use these values or needed to expose them to the client, you could output them directly in your ASPX pages using code-blocks :

    The current user is <%= Session["UserName"] %> and he is <%= Session["Age"] %> years old.

    or within the code-behind of one of your pages as such :

    UserNameTextBox.Text = Session["Username"];
    AgeTextBox.Text = Session["Age"];

    Just to reiterate : any values that you store within the Session will only be available from the server-side unless you explicitly output these values to the client.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 1, 2014 8:45 AM

All replies

  • User281315223 posted

    Hi Santosh,

    Can you be a bit more specific about exactly what you are looking for with regards to these topics. Application Management and Session Management are bold fairly vague terms and they could be interpreted in many ways. 

    I'm a bit unsure about exactly what you are looking for with regards to Application Management, which might be something like all of the different forms of State Management within ASP.NET applications. Session Management is a bit more straightforward, although there are two major types of "Sessions" to consider. There is the Session State, which is used as a form of temporary, user-level storage and allows values to be stored in a Dictionary that will only be available to the user :

    // Example setting a value in the Session
    Session["Key"] = "Example";
    
    // Example accessing a value from the Session
    var example = Session["Key"];

    The Session itself is handled at the Application-level and because of this, it will persist across multiple pages or areas of an application and can be used to store user-specific information that might be reused throughout the application. The other type of Sessions involve actual User Sessions and are generally implemented using Forms Authentication (default in most ASP.NET applications). This is the process of a user entering in appropriate credentials and being authenticated into your application, the "Session" in this case would be defined as the duration that this user stays logged into your application.

    Friday, October 31, 2014 2:50 PM
  • User-389434962 posted

    sir actually why we go for session is if we want to maintain sensitive data to kept in Server Side......k

    for that reason in client side we do not have any specific information about that sensitive data but it is visible to all

    for example

       if maintain UserName:Rion and Age=13 in session means session["UserName"]="Rion"; and session["Age"]="12";

    but this information also visible in client side ((i.e)RightClick on Browser and Click View Source Page )

    so what i am asking is how do we mentain small amount sensitive of user data by using Session.............................!!!!!!!!!!!!!!!!Innocent

        

    Saturday, November 1, 2014 12:44 AM
  • User281315223 posted

    The Session is not going to be visible via the client unless you explicitly output it to the client. So if you created two Session values as you mentioned and stored the UserName and Age within them as follows :

    // Store these two values in the Session
    Session["Username"] = "Rion";
    Session["Age"] = "13";

    There is no way for a user to access this information unless you expose it yourself. They will not be able to see it by viewing the source or digging around using the Developer Tools (F12) within their browser. If you did actually need to use these values or needed to expose them to the client, you could output them directly in your ASPX pages using code-blocks :

    The current user is <%= Session["UserName"] %> and he is <%= Session["Age"] %> years old.

    or within the code-behind of one of your pages as such :

    UserNameTextBox.Text = Session["Username"];
    AgeTextBox.Text = Session["Age"];

    Just to reiterate : any values that you store within the Session will only be available from the server-side unless you explicitly output these values to the client.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 1, 2014 8:45 AM