Blogs Hub

by AskGif | Mar 23, 2019 | Category :coding

Learning Routing and AttributeRouting Web API 2 Controllers in MVC with Areas

Learning Routing and AttributeRouting Web API 2 Controllers in MVC with Areas

The Acumen ASP.NET MVC development team started working with the new Web API 2 controllers released with Visual Studio 2013, and quickly hit some important issues that took some research to resolve.   Routing and AttributeRouting and using Web API 2 controllers inside an Area

read more...

by AskGif | Mar 23, 2019 | Category :coding

How to use libgit2sharp to commit to Git repositories in C# ?

How to use libgit2sharp to commit to Git repositories in C# ?

I helped design an interesting deployment strategy for an Azure application. For one of our projects, we have an existing upgrade solution that will distribute new versions of our ASP.NET application to our clients. One of our clients runs in the app in Azure. To support this automated distributi

read more...

by AskGif | Mar 23, 2019 | Category :coding

Using Moq to Mock Entity Framework DBSet objects

Using Moq to Mock Entity Framework DBSet objects

Unit testing in .NET is pretty nice when your dependency injection/IoC is set up well, but Entity Framework 6 isn’t the nicest framework for mocking and testing. If you’re using ASP.NET MVC 5, you may have run into this scenario.   Problem: You want to use or mock

read more...

by AskGif | Mar 21, 2019 | Category :coding

Ninject InSingletonScope still creates new objects

Ninject InSingletonScope still creates new objects

Me: Kernel.Bind<IDataCache>().To<InMemoryDataCache>().InSingletonScope(); Ninject: Haha, nah. Here’s a new object bro. I don’t know why exactly this happens but for some reason, I’ve seen it happen in more than one project. Binding an implemen

read more...

by AskGif | Mar 21, 2019 | Category :coding

Correct way to Inject MVC and HTTP attributes and filters using Ninject

Correct way to Inject MVC and HTTP attributes and filters using Ninject

Ninject has some fun quirks. For instance, one "bug" I came across was that if you hit an ASP.NET controller with a custom attribute, the attribute&rsquo;s constructor-injected dependencies would be null on startup. For example, take the following ActionFilterAttribute: <pre class="language-

read more...

by AskGif | Mar 21, 2019 | Category :coding

Ninjecting in App_Start classes and static classes

Ninjecting in App_Start classes and static classes

Let's say you are doing some work on your AuthConfig class, in your Global.asax, or maybe a static class. You can&rsquo;t property-inject, and generally, it&rsquo;s a pain to get this to work. &nbsp; However, if you&rsquo;re using Ninject for ASP.NET MVC, you can use the following

read more...

by AskGif | Mar 20, 2019 | Category :coding

How to use ASP.NET Web API cross-origin with ASP.NET Identity ?

How to use ASP.NET Web API cross-origin with ASP.NET Identity ?

ASP.NET Web API is a fantastic piece of the .NET family (there is certainly some weirdness since we now have MVC and Web API with nearly identical methods, but ASP.NET MVC 6 is coming :)). However, getting a SPA or mobile hybrid (Ionic!) app working isn&rsquo;t the most pleasant experience.

read more...