Master Pages and service reference

Discussion in 'ASP .Net Web Services' started by Alex, Jun 4, 2009.

  1. Alex

    Alex Guest

    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 get the
    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
     
    Alex, Jun 4, 2009
    #1
    1. Advertising

  2. Alex

    Tanzim Saqib Guest

    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 <.(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
     
    Tanzim Saqib, Jul 8, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Electrified Research
    Replies:
    5
    Views:
    2,502
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    Oct 11, 2005
  2. Doug McCann
    Replies:
    1
    Views:
    1,136
    William Brogden
    Aug 5, 2004
  3. Replies:
    1
    Views:
    3,279
    PeterKellner
    May 16, 2006
  4. Sam
    Replies:
    0
    Views:
    723
  5. Sam
    Replies:
    1
    Views:
    805
Loading...

Share This Page