aspx Tutorial

.NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services, .NET articles, Sharepoint 2010, visual studio 2010,Aamir Hasan,IT, Building Your First Web Application Project
Advertise Here

Toolbar

Get our toolbar!

Advertize



Posted by Aamir Hasan   on Sunday, February 27, 2011 Total Views:  

Web services have not any mechanism by which can maintain state. But web services  can access asp.net objects like Session, Application and so on if they are inherit from web services bass class.

In this article, I would demonstrate how Session and Application Object can maintain by Web Services. I have created a web form called Session-Application.aspx, which only includes a buttons named. If you click on a button, an event is triggered, and the Web service calls:

Session Object

Session objects store information between HTTP request for a particular user.

Example

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">

    <div>

        <p>

            <asp:Button ID="BtSession" runat="server" Text="Session"
           
 OnClick="BtSession_Click" />

        </p>

    </div>

    </form>

</body>

</html>

 

C#

    protected void BtSession_Click(object sender, EventArgs e)

    {

        Session["Session"] = "aspxtutorial.com";

 

        MyWebServices WS = new MyWebServices();

        Object T = WS.getSessionValue();

     

        Response.Write(T);

    }

 

VB.NET

    Protected Sub BtSession_Click(sender As Object, e As EventArgs)      

        Session("Session") = "aspxtutorial.com"      

        Dim WS As New MyWebServices()

        Dim T As [Object] = WS.getSessionValue()

        Response.Write(T)

    End Sub

 

Here is a preview of the Object that will be returned.

 

Application Object

Application object can be used in situation where we want data to be shared across users globally.

Download

Session-Application.rar (2.36 kb)

See Live Demo

Protected by Copyscape Online Plagiarism Tool

Comments (3) -

hogan scarpe
hogan scarpe People's Republic of China
7/12/2012 11:34:02 PM #

Though facilitating payment program, these outlets <a href="http://www.tophoganoutlet.com/">hogan scarpe</a> helps you to access broad array of collections at sensible  rates.

GATE coaching in Bangalore
GATE coaching in Bangalore India
2/5/2013 11:33:06 PM #

GATE coaching in Bangalore, GATE coaching center in bangalore, IES coaching  in Bangalore, PGCET coaching in Bangalore, GATE coaching bangalore at global academy.

Shila Commendatore
Shila Commendatore United States
9/20/2013 3:06:39 AM #

Hi there, I discovered your web site by means of Google while searching for a comparable subject, your website got here up, it appears great. I have bookmarked it in my google bookmarks.

newasiainconline.com
newasiainconline.com United States
3/8/2014 8:20:23 PM #

I constantly emailed this webpage post page to all my associates, because if like to read it next my friends will too.|

Chinese Restaurant Supplies
Chinese Restaurant Supplies United States
3/22/2014 1:49:32 PM #

I like it whenever people come together and share thoughts. Great website, keep it up!|

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5