code_junkie

best way to persist data in .NET Web Service

Nov 10th, 2011
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. Context.Cache.Insert("foo", _
  2. Foo, _
  3. Nothing, _
  4. DateAdd(DateInterval.Minute, 30, Now()), _
  5. System.Web.Caching.Cache.NoSlidingExpiration)
  6.  
  7. <WebMethod(CacheDuration:=60)> _
  8. Public Function HelloWorld() As String
  9. Return "Hello World"
  10. End Function
  11.  
  12. public class WebServiceClass
  13. {
  14. private static DataTable _myData = null;
  15. public static DataTable MyData
  16. {
  17. get
  18. {
  19. if (_myData == null)
  20. {
  21. _myData = ParseJsonDataReturnDT();
  22. }
  23. return _myData;
  24. }
  25. }
  26.  
  27. [WebMethod]
  28. public string GetData()
  29. {
  30. //... do some stuff with MyData and return a string ...
  31. return MyData.Rows[0]["MyColumn"].ToString();
  32. }
  33. }
Add Comment
Please, Sign In to add comment