milani_lucie
asked on
Session Management Using WCF - Silverlight
Hi,
I want to handle Session Management using WCF in Silverlight. Here is the sample code:
========================== ========== ========== ========== ========== ========== =
Imports System.ServiceModel
<ServiceContract(Namespace :="")>
Public Interface IService1
<OperationContract()>
Sub SetSessionVariable(ByVal SessionKey As String, ByVal SessionValue As String)
<OperationContract()>
Function GetSessionVariable(ByVal SessionKey As String) As String
End Interface
========================== ========== ========== ========== ========== ========== =
Imports System.ServiceModel.Activa tion
<AspNetCompatibilityRequir ements(Req uirementsM ode:=AspNe tCompatibi lityRequir ementsMode .Allowed)> _
Public Class Service1
Implements IService1
Public Sub SetSessionVariable(ByVal SessionKey As String, ByVal SessionValue As String) Implements IService1.SetSessionVariab le
System.Web.HttpContext.Cur rent.Sessi on(Session Key) = SessionValue
System.Web.HttpContext.Cur rent.Sessi on.Timeout = 20
End Sub
Public Function GetSessionVariable(ByVal SessionKey As String) As String Implements IService1.GetSessionVariab le
Return System.Web.HttpContext.Cur rent.Sessi on(Session Key)
End Function
End Class
========================== ========== ========== ========== ========== ========== =
Private Sub MainPage_Loaded(sender As Object, e As System.Windows.RoutedEvent Args) Handles Me.Loaded
Dim svc As New ServiceReference1.Service1 Client()
svc.SetSessionVariableAsyn c("Key", "Hello World !")
End Sub
========================== ========== ========== ========== ========== ========== =
I am getting "Object reference not set to an instance of an object." at:
System.Web.HttpContext.Cur rent.Sessi on(Session Key) = SessionValue
Can you please change my code and make it working ? My WCF Service is in .WEB project. I am accessing that by using proxy in Silverlight project.
Thanks
I want to handle Session Management using WCF in Silverlight. Here is the sample code:
==========================
Imports System.ServiceModel
<ServiceContract(Namespace
Public Interface IService1
<OperationContract()>
Sub SetSessionVariable(ByVal SessionKey As String, ByVal SessionValue As String)
<OperationContract()>
Function GetSessionVariable(ByVal SessionKey As String) As String
End Interface
==========================
Imports System.ServiceModel.Activa
<AspNetCompatibilityRequir
Public Class Service1
Implements IService1
Public Sub SetSessionVariable(ByVal SessionKey As String, ByVal SessionValue As String) Implements IService1.SetSessionVariab
System.Web.HttpContext.Cur
System.Web.HttpContext.Cur
End Sub
Public Function GetSessionVariable(ByVal SessionKey As String) As String Implements IService1.GetSessionVariab
Return System.Web.HttpContext.Cur
End Function
End Class
==========================
Private Sub MainPage_Loaded(sender As Object, e As System.Windows.RoutedEvent
Dim svc As New ServiceReference1.Service1
svc.SetSessionVariableAsyn
End Sub
==========================
I am getting "Object reference not set to an instance of an object." at:
System.Web.HttpContext.Cur
Can you please change my code and make it working ? My WCF Service is in .WEB project. I am accessing that by using proxy in Silverlight project.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.