Posts

Showing posts from 2018

Update: Single connection string for Multiple Developers

Image
https://dcdevs.blogspot.com/2017/06/single-connection-string-for-multiple.html If you have implemented the trick above, you may have noticed it has stopped working when you moved to a .NET Core project. This is because the DB connection alias is achieved via registry keys which is a Windows-specific behavior. .NET Core supports cross platform development, so Microsoft elected not to implement this Windows-only feature. However, .NET Core provides a new way to manage such configurations across developers - user secrets. In Visual Studio, right click on the project that contains your appsettings.json file and navigate to manage user secrets. User secrets are machine only - Visual Studio will not try to check them in to source control. Here, you can mimic the structure of your appsettings.json to overwrite any configuration setting - not just the connection string! Any values you define here will overwrite the corresponding appsettings.json value (hierarchy must match).

User Registration with CAC/Client Certificates in Asp.Net made easy - PART I

Implementing CAC registration in Asp.Net web applications is fairly vague and mystified. Quite frankly, there just isn't a lot of literature on this topic, and what is out there tends to be rather old and not very comprehensive. That said, I'd like to share a way to implement a CAC registration in your Asp.Net web applications. Note, this article is only going to cover things from the .Net Application perspective. For more info on setting up CAC/Client Certs in general, view our other articles. https://dcdevs.blogspot.com/2017/06/iis-express-client-certificates.html https://dcdevs.blogspot.com/2017/06/aspnet-mvc-how-to-enabledisable_19.html The first thing to do is to create a class that can take in a ClientCertificate, validate it, and parse out the information needed to create an account. Here is an example of a CertificateManager class that can be used in your app. public class CertificateManager { public Boolean HasCertificate { get; } pub

Getting Identity Claims to update immediately

Image
Asp.Net Identity Claims are a very useful feature for adding extra metadata to a user's account. This metadata could consist of a user's organization, affiliation, or even profile settings that they can set through the app. In the latter case of having claims values that can be updated dynamically, you will want to have the changes to these values reflected as soon as possible to avoid potential UX issues. By default, claims are refreshed when a user logs into the app. In the case of users who stay logged in for prolonged periods, we want to have control over the interval for when the claims cookie gets refreshed from the database. The default interval that Identity sets for you is not ideal for dynamically updated claims values. It is located in Startup.Auth.cs (assuming this is standard .Net MVC project). As you can see in the screen above, the default is set to 30 min. To configure claims values to update more quickly, just change the Timespan to something like.

Stop Visual Studio from Eating Disk Space

Image
If you you Visual Studio and NuGet, chances are that you have been affected by this issue! Navigate to \Users\{Your username}\AppData\Local\Temp\NuGetScratch and check the size of the folder. In my case, I had 40GB  of temporary files that have never been cleaned up. Now in Visual Studio, navigate to Tools > NuGet Package Manager > Package Manager Settings In the dialog box, click Clear All NuGet Cache(s). This will empty out several temporary folders, including the previously mentioned NuGetScratch which is the worst offender. Note that this operation may take some time and Visual Studio may be unresponsive while the operation completes. Thanks for reading!

Web Config Transformations

Web config transformations allow for developers to cut down on duplicated XML in configuration files by providing a way to change only the non-static values for the appropriate environment. A value that would be expected to change between environments is something like a connection string, whereas library versions would remain the same for any deployment of an application. Transformations can be tricky: often times developers do not have the required access to view the transformed version of the file on a production environment. The best way to configure your transformations is to use a site like the one below which uses the same transformation functions as the build and shows you the output. https://webconfigtransformationtester.apphb.com/ https://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx The second link above is to Microsoft's documentation of the possible transforms. The key takeaway from this reference is the purpose of Transform and Locator . Transform