Solved

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

Posted on 2007-04-09
13
429 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
  • 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now