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
Solved

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

Posted on 2007-04-09
13
430 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

790 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