Hot answers tagged asp.net
The underlying issue is not Session or Asp.Net specific, it is a fundamental issue in how collections in statically typed languages work. The Session object is designed to let you store objects of any type. This means the static type of the stored items must be Object. So Session is equivalent to a Dictionary<string, Object>. Since the compiler can ...
What you're suggesting is not possible, because the type of the assigned variables cannot be known until runtime. Remember that session is effectively shared between all modules used in creating the page. Some of these may not be known at compile time. Therefore you either need to specify the type, or move the check to runtime by using object or dynamic. ...
Session is effectively a map/dictionary with a key that is a string, and a value that is an object. It predates generic types in C#/ASP.Net, and would more likely be an IDictionary<string,dynamic> today, which would support what you are trying to do. //you cannot do this either... //default from a session is an object/null, not even an integer object ...
Time on a date-only object is usually midnight. So if you add one to your ending day, you'll get the correct range; it will include the entire last day, up to midnight.
It depends. How is the result meant or expected to be used? If it should be a string (i.e. no associated json semantics), then return it as a string. If you wish to use of the facilities associated with the json data, then keep the JsonResult. If you are unsure, keep the JsonResult and let the client convert it if they require it to be just a string.
Only top voted, non community-wiki answers of a minimum length are eligible