Click here to Skip to main content
15,921,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to initialize some values(variables) in web service method that will be used in every web method,without using session var (httpContext)

i guess variables will lose its values , in every method



XML
<ServiceContract(Namespace:="")>
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)>
Public Class Service

    Dim a As Integer
    dim b As Integer
    <OperationContract>
    Public Function init2(ByVal a1 As Integer, ByVal b1 As Integer) As Integer
        a = a1
        b = b1
        
        Return a1 + b1
    End Function

    <OperationContract()>
    Public Function DoValue() As Integer
        Return  a+ b    End Function

End Class
Posted

Yes, I would imagine so. The web is stateless. What happens when several people are using your webservice at once ?
 
Share this answer
 
v2
state should be maintin for one instance (one session), other users will get theier own states (sessions) , its like one instance of the class should maintain the value among the methods
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900