Make sure you have EnableSession = true on top of your WebMethod:
[WebMethod(EnableSession = true)]
Tanzim Saqib
W:
http://TanzimSaqib.com
On Jun 4, 10:30*pm, Alex <alex_d...@adp.com.(nospam)> wrote:
> I created a web service in my web application that needs to update a session
> variable. I call the web service from a master page using java script. My
> Script Manager is defined as
>
> <asp:ScriptManager ID="ScriptManager1" runat="server" >
> * * * * * * <Services>
> * * * * * * * * <asp:ServiceReference Path="~/Web Services/e2WS.asmx"
> InlineScript="True" />
> * * * * * * </Services>
> </asp:ScriptManager>
>
> In my webmethod, I do a simple Session["Culture"] = culture;, but I getthe
> following error: Object reference not set to an instance of an object.
>
> If I pass the value to a class that inherits from System.Web.UI.Page and I
> try to set the session variable, I get the following error:
> Session state can only be used when enableSessionState is set to true,
> either in a configuration file or in the Page directive. Please also make
> sure that System.Web.SessionStateModule or a custom session state module is
> included in the <configuration>\<system.web>\<httpModules> section in the
> application configuration.
>
> Now, I made sure that enableSessionState and the
> System.Web.SessionStateModule *is included in m,y config file, but still no
> luck.
>
> Is this something to do with the fact that the java script started off in
> the master page which inherits from System.Web.UI.MasterPage?
>
> Alex