使用SessionMode = SqlServer在WCF Servive中进行Mentain会话。 [英] Mentain Session in WCF Servive using SessionMode=SqlServer.

查看:531
本文介绍了使用SessionMode = SqlServer在WCF Servive中进行Mentain会话。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的wcf服务来获取和设置会话但是我收到了一些错误

i做了这样的事情:



Intesface:

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 :

[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 :

[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 :

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

       String Sessionvalue = obj.GetSession();
   }







我收到错误As:






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..

推荐答案

如果您正在处理大数据,您需要修改Web服务中的配置文件以接受更大的输入字符串。添加以下行为我解决了这个问题。



If you are working on large data,You need to modify the config file in the web service to accept larger input strings.Adding the following line resolved this issue for me.

<system.web>
   <httpRuntime maxRequestLength="32768" />
</system.web>





你可以在这里阅读更多的可能性,



http://social.msdn.microsoft.com/Forums/vstudio/en-US/686499d2-5e31-47ee-941b-760264472875/an-error-occurred-while -receiving-the-http-response-to-xxx-problem-wcf-comunication?forum = wcf [ ^ ]



HTTP://forums.asp。净/吨/ 1992969.aspx?一个+误差+ +发生而+ +接收的+ HTTP +重赞助+这+可以+ + +到+ + + +服务+端点+绑定+不+使用+ + HTTP +协议 [ ^ ]





http://stackoverflow.com/questions/15821687/wcf-an -rorror-while-receive-http-response-to-http-xxxxx-servic [ ^ ]



And you can read more possibilities here ,

http://social.msdn.microsoft.com/Forums/vstudio/en-US/686499d2-5e31-47ee-941b-760264472875/an-error-occurred-while-receiving-the-http-response-to-xxx-problem-wcf-comunication?forum=wcf[^]

http://forums.asp.net/t/1992969.aspx?An+error+occurred+while+receiving+the+HTTP+response+This+could+be+due+to+the+service+endpoint+binding+not+using+the+HTTP+protocol[^]


http://stackoverflow.com/questions/15821687/wcf-an-error-occurred-while-receiving-the-http-response-to-http-xxxxx-servic[^]


这篇关于使用SessionMode = SqlServer在WCF Servive中进行Mentain会话。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆