WCF 서비스에서 asp.net 세션에 액세스하려고합니다. 내wcf 서비스 내 asp.net 응용 프로그램에서 호출하고 있습니다. 나는 많은 SO 질문 및 기사를 통과하고 그들이 말한 모든 것을 시도했지만 여전히 나는 wcf 서비스에서 클라이언트 세션에 액세스 할 수 없다. DataSet ds = HttpContext.Current.Session["data"] as DataSet;
이라고 쓰면 ds
은 항상 null입니다.wcf 서비스에서 asp.net 세션에 액세스 할 수 없습니다.
무엇이 여기에 있습니까? 내가 Global.asax
의 session_start
의 데이터 세트를 생성하고 세션에 넣어하고 // 인터페이스
[ServiceContract(SessionMode = SessionMode.Allowed)]
public interface IMyService
{
[OperationContract(IsInitiating=true)]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
string GetData();
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
bool SaveData(string data);
}
// 서비스
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class MyService : IMyService
{
public string GetData()
{
return "something";
}
public bool SaveData(string data)
{
DataSet ds = HttpContext.Current.Session["data"] as DataSet;
return true;
}
}
:
이 내 WCF 서비스가 같은 모습입니다 그래서 나는 사용자 세션이 유효한 한 응용 프로그램에서 사용할 수 있습니다.
<service name="MyService">
<endpoint address="" behaviorConfiguration="JSONPBehaviorConfiguration"
binding="customBinding" bindingConfiguration="jsonpBinding"
contract="IMyService">
</endpoint>
</service>
<customBinding>
<binding name="jsonpBinding" >
<jsonpMessageEncoding />
<httpTransport manualAddressing="true"/>
</binding>
</customBinding>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
예. 저기에있어. – Asdfg
나는 내 서비스에 AJAX 호출을하고 있기 때문에 작동하지 않습니까? – Asdfg
남자가 작동하지 않았다! –