tentavarious
asked on
Can't set a session variable with ajax asp.net 1.1???
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
"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
Are you talking about the Microsoft AJAX framework? Or AJAXPro?
Bob
Bob
ASKER
I believe its the microsoft ajax framework, but I am not real sure, where do i check?
Look at the project references, and see what DLL is being referenced for the AJAX implementation.
Bob
Bob
ASKER
It just says AJAX
Does the \bin folder have any DLL files that are related to AJAX?
Bob
Bob
ASKER
Just the Ajax.dll file it does say below the file name Ajax.net Wrapper. That is all I have in that folder.
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(AjaxPr o.HttpSess ionStateRe quirement. ReadWrite) ]
public void Test5(string value)
{
System.Web.HttpContext.Cur rent.Sessi on["exampl e"] = value;
}
[AjaxPro.AjaxMethod(AjaxPr o.HttpSess ionStateRe quirement. Read)]
public string Test6()
{
if(System.Web.HttpContext. Current.Se ssion["exa mple"] != null)
return (string)System.Web.HttpCon text.Curre nt.Session ["example" ];
return "First set the value...";
}
Bob
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(AjaxPr
public void Test5(string value)
{
System.Web.HttpContext.Cur
}
[AjaxPro.AjaxMethod(AjaxPr
public string Test6()
{
if(System.Web.HttpContext.
return (string)System.Web.HttpCon
return "First set the value...";
}
Bob
ASKER
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.Cur rent.Sessi on("exampl e") = sval
Catch ex As Exception
Dim e As String
e = ex.Message
End Try
Do i need to download an update to ajax?
Try
System.Web.HttpContext.Cur
Catch ex As Exception
Dim e As String
e = ex.Message
End Try
Do i need to download an update to ajax?
ASKER
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.Cur rent.Sessi on("exampl e") = 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.
<Ajax.JavascriptMethod()> _
Public Function getstation2(nameval as string)
'Gets the current pace
Dim sval As String
Try
System.Web.HttpContext.Cur
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.
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
Bob
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
But then I get this error Object not set to an instance of an object