I have an *.asmx page running inside a sharepoint public web site. I created the page so that I can call make WebMethod calls from javascript using asp.net AJAX. I followed the instructions in http://msdn.microsoft.com/hi-in/library/ms464040.aspx, which basically contains these steps:
-
Create a separate web application with the *.asmx page.
-
Build it and put the *.dll in the GAC.
-
Run disco on the .asmx page, and copy the .asmx, .disco, and .wsdl files into the ISAPI folder in the 12 hive of Sharepoint.
-
Edit the asmx file to point to the dll in the GAC instead of the code behind.
It works--I can hit the webpage in the sharepoint site and call my webmethod in javascript. The only problem is that Session is null inside the web method. I need Session to pass to various middle-tier components that read from HttpContext.Current.Session. When session is null these components blow up.
I enabled session in the WebMethod attribute [WebMethod(true)], and session is enabled in the web.config.
Am I barking up the wrong tree? Is there any way to pass the Sharepoint web site session into my WebMethod?
When I debug I can see that the sessionid cookie is being passed correctly from Sharepoint to my WebMethod. For some reason my WebMethod is failing to instantiate the Session.