Solved

Can't set a session variable with ajax asp.net 1.1???

Posted on 2007-04-09
13
433 Views
Last Modified: 2011-09-20
Experts I am trying to set a session variable using ajax and I keep getting this error:
"Session State can only be used when the enabled session sate is set to true either in configuration file or page directive. "

 I have never had this problem before setting session's its just when I try to set a session with an ajax function

 <Ajax.JavascriptMethod()> _
       Public Function setweekly(sval as string)
try
       Session("statename") = sval
catch ex as exception
sval = ex.message
end try
return sval
    End Function
0
Comment
Question by:tentavarious
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 

Author Comment

by:tentavarious
ID: 18876878
I tried this HttpContext.current.session("statename") = sval
But then I get this error Object not set to an instance of an object
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 18877088
Are you talking about the Microsoft AJAX framework?  Or AJAXPro?

Bob
0
 

Author Comment

by:tentavarious
ID: 18877417
I believe its the microsoft ajax framework, but I am not real sure, where do i check?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 96

Expert Comment

by:Bob Learned
ID: 18877450
Look at the project references, and see what DLL is being referenced for the AJAX implementation.

Bob
0
 

Author Comment

by:tentavarious
ID: 18877920
It just says AJAX
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 18881105
Does the \bin folder have any DLL files that are related to AJAX?

Bob
0
 

Author Comment

by:tentavarious
ID: 18882062
Just the Ajax.dll file it does say below the file name Ajax.net Wrapper.  That is all I have in that folder.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 18883493
Ok, so now it is sounding like Ajax.NET Pro:

http://ajaxpro.schwarz-interactive.de/

Session State handling with Ajax.NET
Now, we you can access your session variables, there was a small bug.

On the server the C# method looks like following code:

[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
public void Test5(string value)
{
  System.Web.HttpContext.Current.Session["example"] = value;
}

[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.Read)]
public string Test6()
{
  if(System.Web.HttpContext.Current.Session["example"] != null)
    return (string)System.Web.HttpContext.Current.Session["example"];

  return "First set the value...";
}

Bob
0
 

Author Comment

by:tentavarious
ID: 18883588
Not sure what is going on but I keep getting this error: Object not set to an instance of an object when I try your code.  I am using vb.net so I made a small change:

      Try
            System.Web.HttpContext.Current.Session("example") = sval
        Catch ex As Exception
            Dim e As String
            e = ex.Message
        End Try

Do i need to download an update to ajax?
0
 

Author Comment

by:tentavarious
ID: 18883723
Ok, I dont think I have ajax pro my attribute is different from yours

 <Ajax.JavascriptMethod()> _
     Public Function getstation2(nameval as string)
        'Gets the current pace
        Dim sval As String
             Try
            System.Web.HttpContext.Current.Session("example") = sval
        Catch ex As Exception
            Dim e As String
            e = ex.Message
        End Try
        Return sval
    End Function

I tried using this attribute tag instead
 <Ajax.JavascriptXmlHttp()> _

but it doesnt like that I get an error.
   
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 18886555
That is why it is important to understand what version of AJAX that you are using.  Without specific information, it will be very difficult to provide any guidance.

Bob

0
 

Author Comment

by:tentavarious
ID: 18889419
Alls I know is I downloaded a free version that works with asp.net 1.1, where can I download the professional version that works with asp.net 1.1?  I was doing some searching and my ajax dll file name is not the same as the professional file name, so I have no idea what version I could be using.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 125 total points
ID: 18889624
You can get Ajax.NET Pro from here:

http://www.codeplex.com/AjaxPro/Release/ProjectReleases.aspx?ReleaseId=713

There are 2 files that you need to use:

For 1.1:
  AjaxPro.dll
  AjaxPro.JSON.dll

For 2.0:
  AjaxPro.2.dll
  AjaxPro.JSON.2.dll

Bob
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question