Solved

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

Posted on 2007-04-09
13
423 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
Comment Utility
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
Comment Utility
Are you talking about the Microsoft AJAX framework?  Or AJAXPro?

Bob
0
 

Author Comment

by:tentavarious
Comment Utility
I believe its the microsoft ajax framework, but I am not real sure, where do i check?
0
 
LVL 96

Expert Comment

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

Bob
0
 

Author Comment

by:tentavarious
Comment Utility
It just says AJAX
0
 
LVL 96

Expert Comment

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

Bob
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:tentavarious
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

6 Experts available now in Live!

Get 1:1 Help Now