Category Archives: ASP.NET

Home / ASP.NET
117 Posts

Earlier today, I was struggling a bit to get a .NET Core application’s authentication mechanism to behave appropriately for both MVC (view) and API (ajax/json) requests. In .NET Core 2.x, handling this is not as straight-forward as it could be, but it’s doable. Effectively, we want a user requesting a view through a normal browser request to get an authentication challenge / login page, but we want API requests to receive a 401 response and end it there. Under normal circumstances, though, both types of requests would receive the login page.

More Link

A while back, I blogged about using open generics with .NET Core Dependency Injection. It really does work great for an out of the box experience. However, one drawback is that you can’t use a factory pattern like you can when injecting in a type-specific way.

More Link

The other day, I wanted to create a really simple console application using .NET Core 2.x. Out of the box, however, it appeared that there were a lot of compromises to a console application as compared to a Web/Kestrel hosted app. The main things that were missing were dependency injection and user secrets.

More Link

Last night I was working on a project that had some many to many database relationships. On one side of the relationship, someone decided to use zero as the default “nothing selected” sort of key. This simply doesn’t work with Entity Framework, or probably most other .NET ORMs.

More Link

This morning I was updating some Data Models in a project, and noticed, based on my project scheme, that I would have to add a derived BaseRepository class. This is a side-effect of the way I’ve used Ninject for a long time and every IRepository<T> is specified to be a BaseRepository<T>. That pattern is a little annoying, and in some ways, is counter-intuitive when dealing with DI and generics.

More Link

A friend of mine asked me yesterday how one would go about having an AutoMapper configuration such that you have multiple mappings for the same object pairs. This is an interesting situation for which I didn’t have an immediate answer. But, after playing around with AutoMapper a bit, my choice was to utilize a factory to provide multiple IMapper instances.

More Link

I’ve written a fair bit of demos for Angular 2.x/4.x using Plunker. Plunker provides a pretty convenient way to demo Angular concepts, but the fact that the code is rendered in the browser doesn’t make it overly useful for building redistributable, or production, applications. Since many people have asked me how to take some of my demos from Plunker to a Visual Studio project, that’s what I decided to do.

More Link

A while back, I blogged about using Quartz for scheduling jobs. Recently, I needed to make an API that could trigger jobs, and I thought of Quartz. There is a need/desire in this use case to prevent concurrent execution of jobs when the API is accessed and triggers jobs, and I didn’t really want to stack/queue jobs either. Quartz has some nice mechanisms to achieve exactly what I wanted.

More Link

A memory leak can very difficult to isolate. I ran into an interesting one a few days ago. I have a service that makes calls to a SOAP service with a serialized SOAP body from POCO, and it digests/deserializes the Xml response into POCO. However, there was a memory leak that I could not locate.

More Link