Posts

Web applications for a Government Audience: Think twice before using Font Icons

Image
Modern web applications make heavy use of icons and beautiful custom text fonts, and for good reason. Icons and custom fonts are awesome when used properly. But what happens when icons and custom text do not appear for a significant portion of users? Icons Take the following example from Data.gov. They have a very nice looking navigation on their homepage that makes great use of font icons.  However, this is how the site looks using Internet Explorer 11 on a government domain such as DOD. On one hand, the icons are only used as supplements and so even though there is a gaping vertical space between each navigation item, usability is still the same. If you follow this principal and always provide text next every icon, worrying about IE users on government domains is not a high priority. There is also a very minor difference in the text fonts although, it's very subtle. Here is another example where the lack of icons causes a greater impact. You can see...

ASP.NET Identity Email Confirmation Token

Image
ASP.NET Identity has an Email Confirmation feature that you can (and should) enable. It will send an email with a token based Url to a registered user to simply confirm their email to allow them access into a web application. That token gets generated & stored in memory and therefore may be lost if the user does not confirm their account promptly. Code Settings Depending on the version of ASP.NET Identity the default  TokenLifespan  setting varies but the most recent version is supposed to be  24 hours  but an earlier version had it set to as low as  3 minutes.  Below is an example of how to set it directly within the  Account  controller to a 12 hour duration, you could inject the  dataProtectorProvider  via an IoC container then pass it to the constructor or just within the default  Startup.cs . public AccountController(IdentityUserManager userManager) { var dataProtectorProvider = Startup.DataProtectionProvider; ...

SSMS Dark Theme

Image
SQL Server Management Studio (SSMS) has no equivalent Visual Studio Dark theme. I've been  recently  spending some unusual amount of time in SSMS working on database setup scripts and Stored Procedures and staring at a white screen all day is too much (for me) so I decided to come up with a theme that matches Visual Studio's default Dark theme with some color enhancements.  Note: This theme only applies to the main editing window. STEP 1  -   Download .vssettings file   STEP 2  - Open SQL Server Management Studio and go to  Tools > Import & Export Settings > Import selected environment settings > Choose Yes to backup your current settings >   Browse to the downloaded file   > Finish. STEP 3  - Since the theme only applies to the main editing window, for best results collapse the Properties and Object Explorer panes. Sample(s) Using some  MSDN samples  you get the following res...

Running multiple scripts via SQLCMD

On some of our applications we have multiple database scripts that we need to run in a specific sequence as part of a release. Using  SQLCMD  you can write a quick and easy script to do the job for you. There are other more involved alternatives such as using a Visual Studio Database Project, using Entity Framework Code First migrations or creating custom builds but sometimes a simple solution is all you need. STEP 1  -  enable  SQLCMD In SQL Server Management Studio (SSMS), go to the Query menu and select  SQLCMD STEP 2  -  connect to a db server this would be the same value as your SSMS connection server name by simply changing this value, you can run these scripts on any other environment :CONNECT mysqlserver.com STEP 3  -  set the variable path move all the scripts you want to run in a single folder and set the full path to it :SETVAR path "c:\myscriptsfolder" STEP 4  -  (optional) add standard T-SQL sta...

Single connection string for Multiple developers

Our development team has been growing as new capabilities and features are being added.  Having to deal with web.config changes and TFS can become frustrating so here's what we found to be the easiest solution without having to manage several *.config files (and additional accompanying sub-config files) and having to deal with what to check-in to TFS and what not to. Database Alias  to the rescue... ask each developer on your team to do the following : STEP 1  - Run SQL Server Configuration Manager   STEP 2  - C heck that  SQL Server Browsing is running - click on  SQL Server Services -  check that    SQL Server Browsing   is set to     Automatic     -  double click > go to Service > change Start to Automatic > Click OK  STEP 3  - Get the TCP/IP Port Number - Under SQL Server Network Configuration, click on  Protocols for ... -   TCP/IP   sh...

IIS Express Client Certificates

We recently had to investigate how to  CAC -enable a web application, one of the challenges was setting up a proper development environment to prototype & test code changes before deploying to other environments. STEP 1  - You need to have a client certificate installed on your development machine. Assuming you don't have a readily available CAC or Smart Card, you can either  create a self-signed certificate  OR for this example we just used a  corporate outlook email client certificate (used to sign & encrypt emails).   Note : The certificate should be available in your web browser. For IE go to  Internet Options > Content > Certificates  to view all your certificates. In Chrome, go to  Settings > Show advanced settings > HTTPS/SSL > Manage certificates . STEP 2  - Using Visual Studio, create a default ASP.NET MVC 5 web application. STEP 3  - Enable SSL for your project. In Visual Studio, hit  F4...

ASP.NET Identity Remember Me

ASP.NET Identity comes with a built-in Remember Me feature on the Login form, it's supposed to keep a user logged in (via an authentication cookie) for a predetermined period of time set via your code settings. However it sometimes might not work as expected and users will have to frequently log in which will cause quite a bit of frustration. Your first reaction is to modify your code then test / rinse / repeat and possibly still see the same unsuccessful results ... did you also check your website's IIS settings? Code Settings Let's first take a look at the Code configuration settings. If you create a new default MVC 5.x application in Visual Studio (with Authentication set to  Individual User Accounts ) the following code is generated (in  /App_Start/Startup.Auth.cs ): app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login"), Provi...