RE: Webservice and session -
05-10-2006
, 08:58 PM
Hi Morten,
Thank you for posting.
As for the SessionState setting for ASP.NET webservice, it is a webmethod
level setting (through the WebMethodAttribute), so there is not directly
property for us to check this in the webservice class. However, if you do
want to check certain WebMethod's SessionState setting, you can consider
using the Reflection api to query the "WebMethodAttribute" attribute. For
example:
===============
MethodInfo mi = this.GetType().GetMethod("HelloWorld",
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.Public);
object[] objs = mi.GetCustomAttributes(typeof(WebMethodAttribute),
true);
if (objs != null && objs.Length >0)
{
WebMethodAttribute wsa = (WebMethodAttribute)objs[0];
if (wsa != null)
{
return "Session: " + wsa.EnableSession;
}
}
============================
BTW, generally, it is not recommended that we use SessionState or other
stateful storage in Webservice since they're platform dependent.
Hope this helps.
Regards,
Steven Cheng
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.) |