How to use Container instead of ObjectFactory in StructureMap ServiceActivator?

The static stuff is going away. If your not using a Service Locator of some type you’re going to have implement your own “ObjectFactory” as referenced here: public static class ObjectFactory { private static readonly Lazy<Container> _containerBuilder = new Lazy<Container>(defaultContainer, LazyThreadSafetyMode.ExecutionAndPublication); public static IContainer Container { get { return _containerBuilder.Value; } } private static Container … Read more

API for Performance and Endurance storage(Block storage)

To order Endurance, execute: Configuration: Package to use = 240 Storage Type: Endurance Location: Dal06 Storage Package: 0.25 IOPS/GB Storage Size: 20GB Snapshot Space Size: 0GB OS Type: Linux URL: https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder Method: POST Json Payload: { “parameters”: [ { “location”: 154820, //Dallas 06 “packageId”: 240, “osFormatType”: { “id”: 12, “keyName”: “LINUX” }, “complexType”: “SoftLayer_Container_Product_Order_Network_Storage_Enterprise”, “prices”: … Read more

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

Constructor Dependency Injection WebApi Attributes

Yes, it is possible. You (like most people) are being thrown by Microsoft’s marketing of Action Filter Attributes, which are conveniently put into a single class, but not at all DI-friendly. The solution is to break the Action Filter Attribute into 2 parts as demonstrated in this post: An attribute that contains no behavior to … Read more

Overload web api action method based on parameter type

This kind of scenario is not well supported by the standard routing methods. You may want to use attribute based routing instead as this gives you a lot more flexibility. Specifically look at the route constraints where you can route by the type: // Type constraints [GET(“Int/{x:int}”)] [GET(“Guid/{x:guid}”)] Anything else will turn into a bit … 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