How to pass json POST data to Web API method as an object?

EDIT : 31/10/2017 The same code/approach will work for Asp.Net Core 2.0 as well. The major difference is, In asp.net core, both web api controllers and Mvc controllers are merged together to single controller model. So your return type might be IActionResult or one of it’s implementation (Ex :OkObjectResult) Use contentType:”application/json” You need to use … Read more

Why should I use IHttpActionResult instead of HttpResponseMessage?

You might decide not to use IHttpActionResult because your existing code builds a HttpResponseMessage that doesn’t fit one of the canned responses. You can however adapt HttpResponseMessage to IHttpActionResult using the canned response of ResponseMessage. It took me a while to figure this out, so I wanted to post it showing that you don’t necesarily … Read more

How to add Web API to an existing ASP.NET MVC 4 Web Application project?

The steps I needed to perform were: Add reference to System.Web.Http.WebHost. Add App_Start\WebApiConfig.cs (see code snippet below). Import namespace System.Web.Http in Global.asax.cs. Call WebApiConfig.Register(GlobalConfiguration.Configuration) in MvcApplication.Application_Start() (in file Global.asax.cs), before registering the default Web Application route as that would otherwise take precedence. Add a controller deriving from System.Web.Http.ApiController. I could then learn enough from the … Read more

Difference between ApiController and Controller in ASP.NET MVC

Use Controller to render your normal views. ApiController action only return data that is serialized and sent to the client. here is the link Quote: Note If you have worked with ASP.NET MVC, then you are already familiar with controllers. They work similarly in Web API, but controllers in Web API derive from the ApiController … Read more

Is there a tag to turn off caching in all browsers? [duplicate]

For modern web browsers (After IE9) See the Duplicate listed at the top of the page for correct information! See answer here: How to control web page caching, across all browsers? For IE9 and before Do not blindly copy paste this! The list is just examples of different techniques, it’s not for direct insertion. If … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)