Solved

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

Posted on 2007-04-09
13
435 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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…
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…
Suggested Courses

751 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