You must Sign In to post a response.
  • Category: Webservices

    Session i n webservice

    Hello,

    how to use session in webservice? and what all r the uses For that i Mentioned below Coding

    <WebMethod(CacheDuration:=60)
    <WebMethod(EnableSession:=True)
  • #455494
    try this


    http://www.dotnetspider.com/resources/17595-Implementing-Session-WebService.aspx

  • #456793
    using System.Web.Services;

    public class Util: WebService {
    [ WebMethod(Description="Per session Hit Counter",EnableSession=true)]
    public int SessionHitCounter() {
    if (Session["HitCounter"] == null) {
    Session["HitCounter"] = 1;
    }
    else {
    Session["HitCounter"] = ((int) Session["HitCounter"]) + 1;
    }
    return ((int) Session["HitCounter"]);
    }
    }

    Regard's
    Rakesh Sharma, NEPL

  • #457598
    Enabling Session Support on the Server
    By default, ASP.NET session support for each Web method is turned off. You must explicitly enable session support for each Web method that wants to use session state. This is done by adding the EnableSession property to the WebMethod attribute of your function. The code for a Web method with the EnableSession property set to true, and which accesses the HttpSessionState object, is shown below.

    Copy Code
    <WebMethod(EnableSession:=True)> _
    Public Function IncrementSessionCounterX() As Integer
    Dim counter As Integer
    If Context.Session("Counter") Is Nothing Then
    counter = 1
    Else
    counter = Context.Session("Counter") + 1
    End If
    Context.Session("Counter") = counter
    Return counter
    End Function

    As you might expect, if you enable session support for one Web method, that does not imply that it is enabled for another Web method. In fact, the Context.Session property will be null if EnableSession is not explicitly set to True for a particular Web method.
    http://msdn.microsoft.com/en-us/library/aa480509.aspx

    Regards & thanks
    Arvind kumar
    Visit--blog.akumars.esoftera.in

  • #460321
    check here,

    http://netprogramminghelp.com/webservices


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.