ASP.Net - Find if a Request is of type Json

By [)ia6l0 iii

You can check the contenttype of the request, and figure out if the request is an JSon request

You can use the following code sample:

bool isJSonRequest = false;
isJSonRequest = Request.ContentType.StartsWith("application/json",   StringComparison.OrdinalIgnoreCase);

Related FAQs

Use the ContentEncoding property of the webresponse to figure out if the response is gzip compressed
Use the "IsSecureConnection" property of the HttpRequest object to find if a Request is from a HTTP or HTTPS connection
You can read the contents of a web page into a string using the HTTPWebRequest class
Use the following code snippet to download an image from an URL.
You can check the contenttype of the request, and figure out if the request is an Ajax request
ASP.Net - Find if a Request is of type Json  (1305 Views)