Showing all posts tagged: 'ASP.NET'

A 24-post collection

.NET Core Dependency Injection with constructor parameters

This post will be short and sweet, albeit one that caused me a bit of a headache. I recently worked on an ASP.NET Core project and I wanted to take advantage of the built-in Dependency Injection service to inject various services to the controllers. However, one of the services required a parameter in the constructor. This is not highly unusual so I was expecting to quickly find an example in the official docs, explaining how to do this. My search, however, returned no results. I then turned to Google/Bing but guess what? Nothing. Every example I found re-iterated …[read more]


Securing ASP.NET Core application settings using Azure Key Vault

Azure Key Vault is one of my favourite services, competing for first place with Azure Functions. And .NET Core is my favorite framework for writing applications. Imagine, then, my suprise when I found out that my favorite tools can now work together! [Azure Key Vault](https://docs.microsoft.com/en-us/azure/key-vault/key-vault-get-started" target="_blank ) is a cloud service for storing sensitive "secrets" and (encryption) "keys". Key Vault is simple, easy and indispensible when developing secure applications. It helps avoid the complexity of storing sensitive information in configuration files. This can be API passwords, …[read more]


ASP.NET Core from the command line

ASP.NET Core (formerly known as ASP.NET 5 or vNext) runs on top of the new [DotNet Core](https://www.microsoft.com/net/core" target="_blank) and is in love with the command line. Although [Visual Studio 2015](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx" target="_blank) is still an excellent IDE and [Visual Studio Code](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx" target="_blank) an amazing code editor, the new iteration of ASP.NET is equally powerful with the command line. ASP.NET Core 1.0 hit RTM on June …[read more]


Using environment variables for application configuration settings

Configuration settings is always a thorny subject. That's because different developers have different preferences on how to do this. In the .NET world, you have the app.config and web.config depending on the project type. Then you can also use [ConfigR](GHOST_URL/introduction-to-configr-the-solution-to-all-your-application-configuration-problems/" target="_blank) or even static XML/JSON files. Another option is to store these settings in the database. There's is no right or wrong answer and you should use whatever works best. However, I recently started working with a new team, where things are not as straightforward when it comes to configuration settings. …[read more]


ASP.NET MVC WebAPI - Optional parameters

[ASP.NET WebAPI](http://www.asp.net/web-api "target="_blank) is a powerful tool for creating APIs quickly and efficiently in .NET. In fact, it takes minimal effort to expose your data through WebAPI though this is both a curse and a blessing. Blessing because it's so easy, curse because you need to be very careful of what you expose. You need to ensure that you're not exposing unwanted information and only provide authenticated access when necessary. Securing WebAPI is a big subject so I'll leave that for another post. Today, I'll show you how to create WebAPI …[read more]


Using HttpHandlers to return XML in ASP.NET

Have you ever had the need to server static XML from your website? Sure you did! If the XML is totally static, then it's pretty simple. You just supply the link to the file and you set your web server to serve and cache your XML data. However, things are a bit trickier if your XML is a serialized object that needs to be served at runtime. In ASP.NET there is a way to do this in an efficient way using an HTTPHandler. In this post, I will show you how to create such a handler and how to …[read more]


Resolving Kestrel issues for ASP.NET 5 on Mac OSx

Running ASP.NET 5 on a Mac is so refreshing! Is it? Really? Well, yes and no. Yes, if you like experimenting and fiddling with the file system, using experimental software and enjoy troubleshooting a lot. It is not a great experience if you expect things to work straight out of the box and you don't want to mess around with the setup and environment configuration. This post is about a couple of this things that I stumbled across a few times while developing and testing ASP.NET on my Mac. Kestrel,in case you haven't used it before, is …[read more]


Server-Side Data in jQuery DataTables with ASP.NET

The jQuery DataTables plugin is my default option whenever I need to display tabular data on a webpage. This is a great jQuery - not to be confused with this jQuery - tool that can be applied to a standard, well-formed HTML table and takes care of all the paging, sorting etc that you may need to apply to any tabular data. It is a very versatile and easy-to-use plugin that can be easily extended with a number of readily available add-ons. It also supports theming, as you would expect from any established jQuery tool. With all of these bells …[read more]