MVC5, Web API 2 and Ninject

The Ninject.Web.WebApi NuGet package has just been released. From now on the preferred solution is using that package. I couldn’t find any related documentation but after installing the package everything worked for me. Install-Package Ninject.Web.WebApi After installation both the normal MVC and the API controller instances are provided by Ninject. If you have Ninject.Web.Common already … Read more

Web API: how to access multipart form values when using MultipartMemoryStreamProvider?

Updated 4/28/2015 You could create a custom provider based on MultipartFormDataRemoteStreamProvider. Example: public class CustomMultipartFormDataProvider : MultipartFormDataRemoteStreamProvider { public override RemoteStreamInfo GetRemoteStream(HttpContent parent, HttpContentHeaders headers) { return new RemoteStreamInfo( remoteStream: new MemoryStream(), location: string.Empty, fileName: string.Empty); } } Updated Custom In-memory MultiaprtFormDataStreamProvider: public class InMemoryMultipartFormDataStreamProvider : MultipartStreamProvider { private NameValueCollection _formData = new NameValueCollection(); private … Read more

The ‘Access-Control-Allow-Origin’ header contains multiple values

We ran into this problem because we had set up CORS according to best practice (e.g. http://www.asp.net/web-api/overview/security/enabling-cross-origin-requests-in-web-api) AND ALSO had a custom header <add name=”Access-Control-Allow-Origin” value=”*”/> in web.config. Remove the web.config entry, and all is well. Contrary to @mww’s answer, we still have EnableCors() in the WebApiConfig.cs AND an EnableCorsAttribute on the controller. When we … Read more

Does IMDB provide an API? [closed]

The IMDb has a public API that, although undocumented, is fast and reliable (used on the official website through AJAX). Search Suggestions API https://sg.media-imdb.com/suggests/h/hello.json https://v2.sg.media-imdb.com/suggests/h/hello.json (as of 2019) Format: JSON-P Caveat: It’s in JSON-P format, and the callback parameter can not customised. To use it cross-domain you’ll have to use their function name for the … Read more