Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a simple wcf service to get and set session but i am getting some error
i have done somthing like this :

Intesface :
C#
[ServiceContract(Namespace = "http://ExpertsExchange.Answers.ServiceContracts/2009/02", Name = "OrderService", SessionMode = SessionMode.Allowed)]
    public interface IService1
    {
        [OperationContract]
        void SetSession(string value);

        [OperationContract]
        String GetSession();
    }


Implementation :

C#
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
   [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
   public class Service1 : IService1
   {
       public void SetSession(string value)
       {
           HttpContext.Current.Session["Test"] = value;
       }
       public string GetSession()
       {
           string value = Convert.ToString(HttpContext.Current.Session["Test"]);
           return value;
       }
   }


Client side code :

C#
protected void Page_Load(object sender, EventArgs e)
   {
       ServiceReference1.OrderServiceClient obj = new OrderServiceClient();
       obj.SetSession("Susheel");

       String Sessionvalue = obj.GetSession();
   }



I am getting error As :

An error occurred while receiving the HTTP response to http://localhost:1908/Service1.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.


Please help me to find out the solution..
Posted

1 solution

 
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