Best practice to call ConfigureAwait for all server-side code

Update: ASP.NET Core does not have a SynchronizationContext. If you are on ASP.NET Core, it does not matter whether you use ConfigureAwait(false) or not. For ASP.NET “Full” or “Classic” or whatever, the rest of this answer still applies. Original post (for non-Core ASP.NET): This video by the ASP.NET team has the best information on using … Read more

How do I get ASP.NET Web API to return JSON instead of XML using Chrome?

Note: Read the comments of this answer, it can produce a XSS Vulnerability if you are using the default error handing of WebAPI I just add the following in App_Start / WebApiConfig.cs class in my MVC Web API project. config.Formatters.JsonFormatter.SupportedMediaTypes .Add(new MediaTypeHeaderValue(“text/html”) ); That makes sure you get JSON on most queries, but you can … Read more

How to use (get and set) httpcontext.current.Session in the class library, within MVC web api application? [duplicate]

First you should get knowledge of Session. Before retrieving HttpContext.Current.Session follow following steps. Set Session Value: HttpContext.Current.Session[“ID”] = value; Get Session Value: var value = HttpContext.Current.Session[“ID”]; Be confirm you have derived System.Web.dll reference in your project Reference You will get error = “Object reference not set….” when key in Session[“ID”] not matched and this is … Read more