Monday, August 31, 2015

Performing a baseless Merge in Team Foundation Server

If you search Google for how to perform a baseless Merge operation, you may come across these articles which require using the command-line:


How To: Perform a Baseless Merge in Visual Studio Team Foundation Server
https://msdn.microsoft.com/en-us/library/Bb668976.aspx


Merge Command
https://msdn.microsoft.com/en-us/library/bd6dxhfy%28v=vs.100%29.aspx

Well, unfortunately, Microsoft has not updated these articles for TFS 2012 and later releases!!

Fortunately, however, this article addresses how to perform a baseless Merge using the User Interface beginning with TFS 2012 and later releases: http://incyclesoftware.com/2012/08/baseless-merge-vs-2012-ui/

It is a great relief to know that you can now perform baseless merges directly using the Visual Studio User Interface and not have to resort to the command line to perform these operations thus making baseless merges much easier to use for the entire development team!

LINQPad 5 Upgrade Licensing

The maker of LINQPad is currently offering a TREMENDOUS discount on LINQPad 5 license upgrades right now!!

http://www.linqpad.net/CustomUpgrade.aspx

To upgrade from a current 1-user license to an Enterprise License, you get a discount of $100 - $132!!

Wow!!!

Truncating and shrinking SQL Server Log Files

If you have your SQL Server databases in Full Recovery mode, you may notice that your SQL Server Log Files will quickly grow in size.

On one of our database servers, I discovered a SQL Server Log File that was over 300 GB in size!

As you can probably guess, I needed to truncate and shrink the log file in order to recover a large amount of disk space.

Fortunately, the process is very easy as is outlined in this MSDN article: https://msdn.microsoft.com/en-us/library/ms189493.aspx

You basically have to set the database to Simple Recovery mode and then run the DBCC SHRINKFILE command.  



SQL Server database connection string on an alternate port

I recently was setting up multiple SQL Server databases on different servers operating on different ports.

However, one of the points of confusion I had remaining was how to connect to these databases in my connection strings when they were operating on ports other than the default port of 1433?

Fortunately, this article came to the rescue!! http://www.connectionstrings.com/sql-server-2012/

In order to connect to a database operating on an alternate port, you specify a connection string such as the following:

Data Source=DBServer,1434;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;

Therefore, you simply separate the port number by a comma, from the database server name (just as you would do in SQL Server Management Studio).

That is all there is to it!!

User, group or role already exists in the current database

I was recently working on creating security users in a new installation of SQL Server when I attempted to assign a user to a restored database and encountered the following error message:


Fortunately, I came across this article which offered a very handy fix:  http://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/

It just told me to run this command to map the database user name back to the database:

EXEC sp_change_users_login 'update_one', 'ColdFusion', 'ColdFusion'

Once I did that, my database login was working once again!!

Friday, August 28, 2015

Discontinuing support for browsers older than Internet Explorer 11

Based on this Microsoft post, browsers older than IE 11 on Windows 7 and later OSes will be discontinued after January 12, 2016: http://blogs.msdn.com/b/ie/archive/2014/08/07/stay-up-to-date-with-internet-explorer.aspx?utm_medium=email&utm_source=eloqua&utm_campaign=dt-ajax-lightweight&elq_n=DT_Ajax%20Lightweight-Email_Q3.Email%201

Windows 8.1 and Windows 10 already ship with Microsoft Internet Explorer 11, so there will be no need to upgrade.

This virtual machine appears to be in use

If you have ever worked with VMWare Workstation and had your Host Windows OS freeze/lock up or crash, you may encounter the following error message:


If you attempt to Take Ownership, you may get the following error message:





Eventually you will discover that you are in an infinite loop that prevents you from ever launching the virtual machine.

So what do you do??

Fortunately, the solution is EXTREMELY SIMPLE!!

On the file system for the virtual machine, you will find a file that ends in the extension: vmx.lck


Once you delete this file from your file system, you will be able to once again launch your virtual machine!!


Thursday, August 27, 2015

Latest Cumulative Updates for SQL Server

If you are looking for the latest updates for your version of SQL Server, then you definitely need to check out this TechNet article: https://technet.microsoft.com/en-us/sqlserver/ff803383.aspx

This article lists out all of the various Cumulative Updates for each release of SQL Server (based on whether or not you have a Service Pack installed).

Wednesday, August 26, 2015

Visual Studio External Tools Limitation

If you use the External Tools feature available in Visual Studio for running your external tools such as MSBuild, you might encounter a severe limitation in the IDE which may prevent you from using Visual Studio as your de facto MSBuild Tool.

When you add an External Tool to Visual Studio, you have the option to specify arguments as well as "Prompt for Arguments"






However, if you look at the length of the arguments that you can specify, you will quickly discover that there is a HARD limit to how many characters that you can add to the Arguments field for your External Tools!

Therefore, if you attempt to create an argument consisting of several hundred characters, you will notice that the Visual Studio IDE will truncate out all of the additional characters from your arguments, thus resulting in unexpected behavior if you do not expect the IDE to truncate your arguments!

So what is the solution to this problem??

Well, you can use an alternative IDE/editor such as EditPlus as described in this article: http://samirvaidya.blogspot.com/2013/10/how-to-run-msbuild-from-editplus-3x.html

Otherwise, you can simply use PowerShell!!


Below is a sample PowerShell script for running MSBuild with Targets and Properties:

$MSBuild = "C:\Program Files (x86)\MSBuild\14.0\Bin\amd64\MSBuild.exe"
$MSBuildProjFile = "C:\MyBuild.proj"
$MSBuildTarget = "PublishProject"
$WebProjectPath = "C:\MyWebProject.csproj"
$SolutionPath = "C:\MyBuildSolution.sln"
$PublishFolder = "C:\Published"
 
 
Clear-Host
 
#Run the MSBuild Command
Write-Host $MSBuild $MSBuildProjFile /t:$MSBuildTarget /p:"SolutionPath=$SolutionPath;WebProjectPath=$WebProjectPath;PublishFolder=$PublishFolder"
& $MSBuild $MSBuildProjFile /t:$MSBuildTarget /p:"SolutionPath=$SolutionPath;WebProjectPath=$WebProjectPath;PublishFolder=$PublishFolder"

Encrypting Configuration Sections in Web.config

If you want to encrypt your Web.config Configuration Sections, then you will definitely want to take a look at these MSDN articles:


How To: Encrypt Configuration Sections in ASP.NET 2.0 Using DPAPI
https://msdn.microsoft.com/en-us/library/ff647398.aspx


How To: Encrypt Configuration Sections in ASP.NET 2.0 Using RSA
https://msdn.microsoft.com/en-us/library/ms998283.aspx

Claims Transformation in ASP.NET MVC

If you are looking for a way to transform claims for Claims Augmentation, then you will definitely want to take a look at the following articles:

How To: Transform Incoming Claimshttps://msdn.microsoft.com/en-us/library/hh987036(v=vs.110).aspx

This series is a 4-part series which goes over Claims Transformation in great detail:

http://dotnetcodr.com/2013/02/25/claims-based-authentication-in-mvc4-with-net4-5-c-part-1-claims-transformation/

http://dotnetcodr.com/2013/02/28/claims-based-authentication-in-mvc4-with-net4-5-c-part-2-storing-authentication-data-in-an-authentication-session/

http://dotnetcodr.com/2013/02/18/introduction-to-claims-based-security-in-net4-5-with-c-part-3-claims-transformation/

http://dotnetcodr.com/2013/02/21/introduction-to-claims-based-security-in-net4-5-with-c-part-4-authorisation-with-claims/


Tuesday, August 25, 2015

Activating IntelliLock

If you have recently purchased IntelliLock for your software licensing needs, you may find it a bit perplexing as to how to activate the software.

You need to follow these steps:

  1. Make sure you drop the Activation License file into the installation directory of IntelliLock
  2. Launch IntelliLock by running as Administrator
  3. From the Help menu, select Activate IntelliLock
  4. You should now be presented with a Hardware ID which you can use to request a Hardware based Activation License File
  5. Once you receive that Hardware ID based Activation License File, you can replace your original Activation License File into the installation directory of IntelliLock
  6. Now, when you click on the Help-->About menu item, you should see that your version of IntelliLock is now fully licensed!




Monday, August 24, 2015

How to change the listening port for Remote Desktop

If you have ever needed to change the default Remote Desktop Port, you probably have consulted this article for modifying the necessary Registry Key for Remote Desktop: https://support.microsoft.com/en-us/kb/306759

However, manually modifying the Registry is time consuming and tedious (especially if you have to do this for a lot of servers), so I created a very convenient PowerShell script to make this process that much easier!!

Licensing mode for theRemote Desktop Session Host server is not configured

I was recently setting up a Remote Desktop Server and after I finished configured the Remote Desktop Session Host, I received the following error message in the RD Licensing Diagnoser:

"Licensing mode for the Remote Desktop Session Host server is not configured."

When I looked on MSDN and came across this article, it offered no insight on how to fix my issue: https://technet.microsoft.com/en-us/library/Cc754487.aspx

Fortunately, I came across this article which provided more insight specifically for Windows Server 2012 R2: http://blogs.technet.com/b/askperf/archive/2013/09/20/rd-licensing-configuration-on-windows-server-2012.aspx

It basically involves selecting "Edit Deployment Properties" from the Tasks menu in order to configure the Licensing for the RD Session Host server:








Support ending for .NET Framework v. 4.5 and v. 4.5.1

If you have not already read the announcement from Microsoft, Microsoft is ending support for .NET Framework v. 4.5 and v. 4.5.1 as of January 12, 2016: http://blogs.msdn.com/b/dotnet/archive/2014/08/07/moving-to-the-net-framework-4-5-2.aspx

Therefore, for any existing applications that you have which are currently using older versions of the .NET Framework, it is recommended that you upgrade your applications to use .NET Framework v. 4.5.2 instead.

The change to support this version of the Framework is very minimal by only requiring a single line version number change in Web.config files.

Based on my initial testing of upgrading to a newer version of the .NET Framework, no changes in functionality were noticeable.


Friday, August 21, 2015

Using a CDN for your Script and Style Content on an SSL-secured ASP.NET Web Application

If you haven't already read about the SSL security features in newer browsers such as Google Chrome and Mozilla Firefox, these browsers are essentially blocking any non-secured content from being downloaded and viewed by the client.

In other words, the "Mixed content" prompt you used to receive while browsing sites with Internet Explorer will not work in browsers such as Google Chrome and Mozilla Firefox.  Instead, you will get an error like the following:






Therefore, if you an SSL-secured ASP.NET Web Site, the best thing to do is to make sure that you always use an SSL Url for your CDN.

For example, the Microsoft Ajax CDN (http://www.asp.net/ajax/cdn) does not publish any of the Urls as https:// Urls, but they are available both on the http:// and https:// protocols.

Other CDNs such as Google CDN (https://developers.google.com/speed/libraries/) and Bootstrap CDN (http://www.bootstrapcdn.com/) publish their CDN Urls as https:// by default.

Finally, other CDNs such as the jQuery CDN (https://jquery.com/download/) makes it clear that you can use either the http:// or https:// protocols since you simply prefix the Url as //code.jquery.com and do not explicitly specify a protocol.


Thursday, August 20, 2015

Checking the version of the .NET Framework installed on your machine

If you are unsure of the version of the .NET Framework that is installed on your machine, you can find that out by looking at your registry as is outlined in this article: https://msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx

You can then compare the Release version in your Windows Registry with the versions outlined in the MSDN article to determine the exact version of the .NET Framework you are running on your machine.

To make this process easier, I have created a very convenient PowerShell script which will tell you the .NET Framework Release version immediately:

$NETFrameworkRegKey = "hklm:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"

$FrameworkReleaseVersion = Get-ItemProperty -Path $NETFrameworkRegKey -Name "Release"

 

 

Clear-Host

Write-Host $NETFrameworkRegKey

Write-Host $FrameworkReleaseVersion.Release

 

switch ($FrameworkReleaseVersion.Release) 

{ 

    378389 {".NET Framework 4.5"} 

    378675 {".NET Framework 4.5.1"} 

    378758 {".NET Framework 4.5.1"} 

    379893 {".NET Framework 4.5.2"} 

    393295 {".NET Framework 4.6"} 

    393297 {".NET Framework 4.6"} 

    default {"The .NET Framework Version could not be determined."}

CS1617: Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default

I was recently attempting to upgrade my existing ASP.NET MVC v. 4.5 Web Application from v. 4.5 to v. 4.5.2.

Unfortunately, when I did this in the IDE, I ended up the the following error message:



CS1617: Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default


Fortunately, the solution was relatively simple!

I just had to change the following section in my Web.config from this:
<system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
</system.codedom>



to this:



<system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:Default" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
</system.codedom>

 

The main line change was really this:

 


<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:Default" />


That was all!

.NET Framework v. 4.6 Targeting Pack

If you are using Visual Studio 2013 and want to target .NET Framework v. 4.6 for your .NET applications, you can download and use the .NET Framework v. 4.6 Targeting Pack from here: http://www.microsoft.com/en-us/download/details.aspx?id=48136&e6b34bbe-475b-1abd-2c51-b5034bcdd6d2=True&751be11f-ede8-5a0c-058c-2ee190a24fa6=True


Windows Identity Foundation Cross-Browser Compatibility Issues

I was recently building an ASP.NET MVC Web Application using .NET v. 4.5 with Windows Identity Foundation and Forms Authentication based on this article: http://brockallen.com/2013/01/26/replacing-forms-authentication-with-wifs-session-authentication-module-sam-to-enable-claims-aware-identity/

Unfortunately, I discovered a very unexpected behavior!!

I tested the following browsers:

  • Internet Explorer 11
  • Google Chrome
  • Mozilla Firefox 39

When I logged in with Internet Explorer 11 and navigated back and forth between 2 WIF Sites (Development and Staging), I was never being redirected from the Forms Authentication window!




When I logged in with Google Chrome and navigated back and forth between 2 WIF Sites (Development and Staging), I was never being redirected from the Forms Authentication window!  Sometimes, I would even lose my FedAuth cookies!!




However, when I logged in with Mozilla Firefox 39 and navigated back and forth between 2 WIF Sites (Development and Staging), everything worked perfectly!!





If you are also experiencing this issue, please vote on this Connect bug here: https://connect.microsoft.com/VisualStudio/feedback/details/1693417

Change your Windows 10 Product Key

If you install an evaluation version of Windows 10 and want to activate it or if you want to upgrade your Windows 10 Home Edition to Windows 10 Pro, you probably want to know how to change your product key to apply your new license.

Fortunately, that is very easy to do!

  1. Go into Settings
  2. Click on Update & Security
  3. Click on the Activation menu item
  4. Click on Change product key to change your Windows 10 Product Key

Slipstreaming updates into Windows 8 and Windows 10

If you have used tools such as nLite, vLite or RT7Lite to slipstream updates in the past, you may be looking for newer releases of these products to support Windows 8, Windows 8.1 and Windows 10.

Fortunately, there are several such tools available to accomplish this now!

  1. DISM: https://technet.microsoft.com/en-us/library/hh824838.aspx
  2. WinReducer: http://www.winreducer.net/
  3. Win Toolkit: http://www.wincert.net/forum/files/file/5-win-toolkit/
  4. NTLite: https://www.ntlite.com/
 As you can probably guess, using Microsoft's DISM tool is by far the most tedious and time consuming, thereby making alternatives such as WinReducer and NTLite more appealing.

WinReducer is commonly used and reviewed throughout the web, and, so far, is the only tool which now supports Windows 10!

NTLite, surprisingly enough, is created by the original creator of nLite and vLite, so the User Interface should be very familiar to those who have used these tools in the past.  NTLite offers both a free version as well as a commercial paid version.

Wednesday, August 19, 2015

Forms Authentication Login Redirection with Authentication Cookie Timeout

I was recently using a Bootstrap template that had static navigation and menu items.  Since we were using this in a _Layout Razor View and using the @RenderBody section for all of our Views, when the Forms Authentication Cookie would time out or expire, we would end up with the Login page inside of our existing _Layout page rather than completely replacing the entire _Layout view!

Well, fortunately, this was fixed through some JavaScript on our _Login view:

<script type="text/javascript">
   if (window.top.location.pathname.indexOf("/Account/Login")<0) 
   {
       window.top.location.href = window.top.location.origin + "/Account/Login";
   }
</script>



If you find it tedious to try and get the exact Url path in JavaScript, you can get the Paths in C# using methods such as the following:



public static string GetLocalPath(HttpContext context)
{
    string baseUrl = string.Empty;
 
    baseUrl = string.Format("{0}://{1}{2}", context.Request.Url.Scheme, context.Request.Url.Authority, context.Request.Url.LocalPath);
 
    return baseUrl;
}
 
public static string GetFQDN(HttpContext context)
{
    string baseUrl = string.Empty;
 
    baseUrl = context.Request.Url.AbsolutePath;
 
    return baseUrl;
}


Then you can assign these values in JavaScript using the following code:



var loginPath = "@UrlHelpers.GetLocalPath(HttpContext.Current)";
var currentPath = "@UrlHelpers.GetFQDN(HttpContext.Current)";


Then your JavaScript just becomes the following:



<script type="text/javascript">
    if (window.top.location.pathname.indexOf("/Account/Login")<0) 
    {
        window.top.location.href = loginPath;
    }
</script>

That is all there is to it!!

Bookmark all open tabs

When I am doing research as part of my Development, it is not uncommon for me to open 100+ tabs or more while I am researching various topics and solutions.


Therefore, it is very convenient to be able to bookmark all of my open tabs in a single operation!

Fortunately, this article describes how to do just that with the various browser platforms such as Mozilla Firefox, Google Chrome and Internet Explorer!

http://www.cnet.com/how-to/how-to-bookmark-all-open-browser-tabs-at-once/

http://www.ghacks.net/2015/08/04/how-to-save-all-open-tabs-quickly-in-your-browser-of-choice/

However, one of the defects I found while using this feature in Mozilla Firefox is that I am always forced to "Bookmark all tabs" into a new folder.  If I want to Bookmark all my open tabs into an existing folder, Firefox does not allow me to do so.  The workaround, of course, is to accept moving them into a new folder and then later use the Bookmark Manage to re-arrange them back into the desired folder and delete the unwanted/unnecessary folder.  

Checking browser capabilities and features

If you are developing a greenfield application using today's modern web technologies such as HTML5, chances are that you want to know what browser features you can and cannot support!

Well, fortunately, this website provides a great breakdown of what features are and are not available in each of the various browser platforms: http://caniuse.com/

You can even do a browser comparison by choosing the browsers you want to compare!

This website will allow you to test the HTML5 features of your current browser and provide you with a ranking: https://html5test.com/

Windows Azure Virtual Machine Partial Service Interruption

Windows Azure just experienced a virtual machine service interruption in parts of the East US.

The latest update is the following:

Virtual Machines - East US - Partial Service Interruption
Starting at approximately 19:30 on 19 Aug 2015 a subset of customers using Virtual Machines in East US may currently be unable to access a small number of deployments in this region. Our Engineers have identified an issue with a supporting Storage service as the root cause, and are currently working to restore availability. The next update will be provided in 60 minutes.

You can continue checking back regarding the Azure Status here:  http://azure.microsoft.com/en-us/status/

Tuesday, August 18, 2015

Team Foundation Server 2015 Released!

Team Foundation Server 2015 went RTM a few weeks ago!  You can read more about what is new in Team Foundation Server 2015 as well as download it from here: https://www.visualstudio.com/en-us/news/tfs2015-vs.aspx

FedAuth Cookies ARE Case-Sensitive!!

I was recently working with Windows Identity Foundation and FedAuth Cookies when I noticed that my application kept on losing my FedAuth Cookie information!

Well, after doing some debugging and troubleshooting with Microsoft, I was able to find this line in my RouteConfig.cs file:

routes.LowercaseUrls = true;

Well, as it turns out, this line was causing my Urls to switch context from /MyUrl to /myurl.  Since my FedAuth Cookies were being created at the time of login, when the Url in my application changes, I suddenly lost my FedAuth Cookies!

Well, once I determined that this behavior was occurring, I decided that I needed to change that code to this instead:

routes.LowercaseUrls =false;

Now my application retained my Url all the way through the application and I no longer lost my FedAuth Cookie information!!

Problem with Lowercase Urls in ASP.NET MVC

As of ASP.NET MVC 4 and beyond, you can change all of your Url Routes to be in lowercase.

However, after I was going through a recent debugging session with Microsoft, doing this has 2 unintended side effects:

  1. Every time I navigate to a Url, the Url is rendered as a 302 redirect in a Fiddler Trace rather than a 200 response in order to display the lowercase Url route.
  2. Any information associated with the non-lowercase Url (such as WIF Session based cookies) are lost because of the route Url context switch!
These changes can be made easily in your ASP.NET MVC Web Application by modifying your RouteConfig.cs file as outlined in this article :

http://gurustop.net/blog/2012/09/01/asp-net-mvc-seo-lowercase-url-iis-rewrite-net45-nuget/

However, since this feature does not work as intended even in ASP.NET MVC 5, it is best to fully verify your application through a Fiddler Trace and IIS Logging before using this feature in your ASP.NET MVC Web Application!!

Configuring IIS Logging

If you have ever wanted to try and track down a difficult IIS-related problem, then you will definitely want to leverage IIS Logging.

You can set up IIS Logging rather easily by following these steps:

  1. Open up IIS Manager
  2. Select a website you wish to configure for Logging
  3. On the Features view tab, click on the Logging icon
  4. Specify a location and time interval for the log files
  5. Click on Apply to begin logging your IIS requests
  6. That is all there is to it to begin logging all of your IIS activity that you can later analyze for troubleshooting and diagnostics!





Thursday, August 13, 2015

Understanding ASP.NET Forms Authentication

If you are trying to understand how ASP.NET Forms Authentication works, this Microsoft Support article provides excellent insight on how Forms Authentication behaves: https://support.microsoft.com/en-us/kb/910443

And in the event that you have to troubleshoot issues with Forms Authentication, you will want to check out this article: https://support.microsoft.com/en-us/kb/910439

Wednesday, August 12, 2015

Claims-Aware ASP.NET Web Applications using Windows Identity Foundation

I was recently researching for a definitive MSDN article on how to implement a Claims-Aware ASP.NET Web Application using Windows Identity Foundation (now built into .NET v. 4.5) and I came across this article:  https://msdn.microsoft.com/en-us/library/hh291061%28v=vs.110%29.aspx

The article provides links to implementing this using ASP.NET Web Forms, ASP.NET MVC both with WIF as well as with Forms Authentication!

Unfortunately, no code samples are provided and no additional details are provided regarding how to customize the Claims information any further, so these articles definitely leave a lot to be desired, but it should at least get you started working with Claims-Aware ASP.NET Web Applications!!

If you want some more detailed information about how to customize this further, you can check out articles similar to this one: http://brockallen.com/2013/01/26/replacing-forms-authentication-with-wifs-session-authentication-module-sam-to-enable-claims-aware-identity/

Tuesday, August 11, 2015

Installing the Visual Studio 2015 SDK

With the release of Visual Studio 2015, Microsoft is now offering the Visual Studio SDK as part of the installation of Visual Studio 2015.  If you forget to install it with Visual Studio, not to worry, you can still install it directly from the Visual Studio 2015 IDE!

Instructions for installing the Visual Studio 2015 SDK can be found here: https://msdn.microsoft.com/en-us/library/bb166441%28v=vs.140%29.aspx






Image compression extension for Visual Studio 2015

If you watched the Visual Studio 2015 Launch Event, you may have heard the speakers talk about a Visual Studio extension that allowed compression of images.

Well, that extension is called "Image Optimizer" and is a free extension for Visual Studio 2015.

You can download it from the Tools-->Extensions and Updates menu.


Netsparker scanning of a secured ASP.NET Web site

I was recently trying to use Netsparker to perform a vulnerability scan of my secured ASP.NET Website (using Forms Authentication), when I discovered that Netsparker could not properly authenticate against my website with the credentials I provided!

Well, Netsparker support provided me with a workaround for using Custom Cookies to authenticate against my website:

https://netsparker.zendesk.com/entries/351822-Custom-Cookies

https://netsparker.zendesk.com/entries/260427-how-can-i-set-custom-cookies-for-a-website

In order to view the necessary custom cookies for your website, you will need to use Developer Tools such as Mozilla Firefox, Google Chrome, IE Developer Tools or Telerik Fiddler to copy the Cookie information and then subsequently paste it into Netsparker for passing the necessary authentication request credentials.


Monday, August 10, 2015

Using SelfSSL7 as an alternative to using IIS Self-Signed Certificates

If you are setting up SSL on your IIS website, you may encounter numerous problems when developing and debugging with the installed SSL Certificate such as this error message: http://samirvaidya.blogspot.com/2015/04/the-remote-certificate-is-invalid.html

Fortunately, there is a better way to use SSL certificates than the Self-Signed Certificate option in IIS which is to use SelfSSL7!

You can download and learn how to use SelfSSL7 here: http://blogs.iis.net/thomad/setting-up-ssl-made-easy

The beauty of using SelfSSL7 is that it automatically adds the SSL Certificate into the Trusted Certificate Store thus removing an extra step required to get an SSL certificate working properly in IIS.

However, drilling down into the Command Line and executing commands is a bit error prone and tedious, therefore, I have created a convenient PowerShell script to accomplish this instead!!

The PowerShell script simply requires the same path information as the command line, but allows the usage of variables to control how the SSL certificate is set up in IIS.

$SelfSSL7 = "C:\SelfSSL7\SelfSSL7.exe"
 
$WebsiteName = "Default Web Site"
 
$CommonName = $env:COMPUTERNAME
 
$LocalHost = "localhost";
 
$ValidityPeriod = "3650"
 
$KeySize = "2048"
 
 
 
Clear-Host
 
$SelfSSLCmd = @"
 
"$SelfSSL7" /Q /T /I "$WebsiteName" /N "cn=$CommonName;cn=$LocalHost"
 
"@
 
Write-Host $SelfSSLCmd
 
& $SelfSSL7 /Q /T /I "$WebsiteName" /N "cn=$CommonName;cn=$LocalHost" /V $ValidityPeriod /K $KeySize | Out-Host



The provided anti-forgery token was meant for user "" but the current user is "user"

I was recently working on adding AntiForgeryToken information to my Claims-based ASP.NET MVC Web Application, when I suddenly encountered the following exception/error message:






After doing a bit of research, I came across this article: http://www.diaryofaninja.com/blog/2014/01/29/htmlantiforgerytoken-ndash-balancing-security-with-usability

It states that the following code can be added to the Application_Start even of your Global.asax file:

AntiForgeryConfig.SuppressIdentityHeuristicChecks = true;

Once I added this code to my Global.asax file, I no longer received this error message!

Saturday, August 8, 2015

Download the Windows 10 ADK

If you are looking for the latest version of the Windows ADK that supports Windows 10, you can download it from here: http://go.microsoft.com/fwlink/p/?LinkId=526740

For more information about Windows Kits and Tools, you can read about them here: https://msdn.microsoft.com/en-us/windows/hardware/dn913721.aspx

Friday, August 7, 2015

The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread’s user context, which may be the case when the thread is impersonating.

I was recently developing an ASP.NET MVC Web Application and adding Claims support for User Information when I suddenly encountered the following error message:

The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.

Fortunately, a quick search on Google returned the following article: https://mytechlifedays.wordpress.com/2012/02/09/the-data-protection-operation-was-unsuccessful-this-may-have-been-caused-by-not-having-the-user-profile-loaded-for-the-current-threads-user-context-which-may-be-the-case-when-the-thread-is-imperso/

The solution was surprisingly simple and only required that the Application Pool be modified to support Loading the User Profile!!  Once I did that, my ASP.NET Web Application worked correctly!!

Clearing Recently Used Files and Projects from Visual Studio 2015

In previous releases of the Visual Studio Productivity Power Tools, you could easily Clear your Recent Files as well as Clear your Recent Projects.

Unfortunately, with the latest release of Visual Studio Productivity Power Tools for Visual Studio 2015, this is no longer possible! https://visualstudiogallery.msdn.microsoft.com/34ebc6a2-2777-421d-8914-e29c1dfa7f5d

Unfortunately, there does not appear to be a replacement Visual Studio 2015 Extension (yet) which can resolve this problem for you, however, you can use this handy dandy PowerShell script to take care of it for you!!


$VisualStudio2015MRUKey = "HKCU\Software\Microsoft\VisualStudio\14.0\MRUItems"
 
Remove-Item -Path Registry::$VisualStudio2015MRUKey -Recurse -Force
After running this script and launching Visual Studio 2015, all of your Recent Files and Projects should be removed from the Start Page and from your Recent Files and Recent Projects menus!!

Troubleshooting .NET Assembly Loading Errors

If you have ever gotten an error message such as the following:





You may want to know how to diagnose and troubleshoot Assembly Loading errors!

Well, fortunately, this is reasonably easy to accomplish using Fuslogvw.exe (Assembly Binding Log Viewer) as described here: https://msdn.microsoft.com/en-us/library/e74a18c4%28v=vs.110%29.aspx






From a Visual Studio Developer Command Prompt (which you Run As Administrator), you simply type fuslogvw.  This will then load the Dialog you see above to allow you to view Assembly Binding/Assembly Loading errors!

You will then be able to view the Log File for any assemblies which failed to load:


That is all there is to it!

Thursday, August 6, 2015

Using Claims-based Forms Authentication with ASP.NET MVC

If you are attempting to use Claims within your ASP.NET MVC Web Application, you may encounter problems if you are not using a Claims Provider such as ADFS as your Claims Issuer.

Since I was using Forms Authentication and the FormsIdentity object, I was encountering a problem whereby only a single Claim was always being returned with my FormsIdentity object.  Based on older code, I was also using a GenericPrincipal object. 

I discovered that I needed to use ClaimsIdentity and ClaimsPrincipal instead in order to add more claims to be passed around with my User Identity as described in this article: http://martinwilley.com/blog/2014/03/07/FormsAuthenticationWithClaims.aspx

Once I solved that problem, since I was sending my own set of Claims from my ASP.NET Web API Service Layer, I suddenly encountered the error message as described in this article: https://stack247.wordpress.com/2013/02/22/antiforgerytoken-a-claim-of-type-nameidentifier-or-identityprovider-was-not-present-on-provided-claimsidentity/

Since I was using AntiForgeryTokens in my ASP.NET MVC Web Application, I was encountering this exception at runtime.

Fortunately, the solution provided in the article for setting the AntiForgeryConfig.UniqueClaimTypeIdentifier in my Global.asax.cs file was just what I needed!!

Tuesday, August 4, 2015

Unable to render CSS for an IIS Website/IIS Application

I had recently set up a brand new ASP.NET Web Application in an IIS Website and Application on Windows Server 2012 R2 complete with an SSL certificate and NTFS permissions. 

Once I had everything set up, I attempted to view the website in a browser.  To my surprise, none of the CSS stylesheets were rendering for the site!!

After a tremendous amount of research on the Internet, I discovered that simply assigning the machine IIS_IUSRS group privilege was insufficient to render all static content on the site!

I ALSO had to add the machine IUSR account to the set of NTFS privileges in order to get my CSS to render properly on the site.

Once I did that, my site was working correctly just as I would expect!!

Undo a checkout made by another user in Team Foundation Server

If you have ever been stuck in a situation where you have to checkout a file and it is currently checked out by another user, you may be wondering if you have to wait until the other user checks in the file or not.

Well, provided you have sufficient privileges in TFS to undo other's checkouts or check in other people's changes, you can do something about it!!

There are 2 tools available for you to accomplish this:

  1. Team Foundation Server 2013 Power Tools: https://visualstudiogallery.msdn.microsoft.com/f017b10c-02b4-4d6d-9845-58a06545627f
  2. Team Foundation Sidekicks: http://www.attrice.info/downloads/index.htm#tfssidekicks2013

The easiest tool to use is definitely Team Foundation Server 2013 Power Tools which integrates with Visual Studio 2013.

  1. You simply find the file that is currently checked out to another user in Source Control Explorer
  2.  Then you right click on the file and select Find-->Find By Status
  3. Once you have pulled up the current list of checkouts, you simply select the person's edit you want to undo and select "Undo"







With Team Foundation Sidekicks, the operation requires that you know the owner of the file as well as the data range when you think the file was checked out.  This makes the operation a bit more difficult because it requires date ranges to be known (or guessed):





Once you have found the file that you want, you simply select "Undo pending change" from the icon in the toolbar.

That is all that is necessary to undo another person's checkout from TFS!

Microsoft Edge detected as Google Chrome!

I have been using ASP.NET Server Side Browser Detection in many of my web applications and I decided to check how Microsoft's new Edge browser would be detected.

Therefore, I decided to try it out and I was extremely surprised by the results!!

The User Agent string that showed up for Microsoft Edge was the following:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240

For the Browser Name property, I ended up with the following:

Chrome

For Browser Version and Browser Type information, I ended up with the following:

42.0
Chrome42


Even with Microsoft's .NET Framework v. 4.6, the result was the same!!

Therefore, until Microsoft fixes this major flaw in their ASP.NET Framework, you will not be able to use Server Side detection for the time being!!

If you want Microsoft to fix this issue, you can vote for this Connect item here: https://connect.microsoft.com/VisualStudio/feedback/details/1626463

 

 

Website support for Microsoft Edge browser

Now that I have installed Windows 10, I have been trying to use Microsoft's new Edge browser as a replacement for Internet Explorer to browse many websites.

Unfortunately, most of the websites in the world today don't properly support the latest and greatest browser from Microsoft including Google's own Blogger!!

When browsing websites with Microsoft Edge, pages often do not render correctly or JavaScript on the page may be broken etc.

Therefore, for now, you are probably better off browsing with either Internet Explorer or preferably Mozilla Firefox, Waterfox or Google Chrome instead for a functional browsing experience!!

Checking Sitefinity Project Feather progress

As you may know, Sitefinity Project Feather is an MVC-oriented project directed towards providing Sitefinity functionality to support ASP.NET MVC and Responsive Design frameworks such as Bootstrap.

Unfortunately, Project Feather is still behind on releasing all of the functionality that was originally released for Sitefinity with ASP.NET Web Forms support.

You can check out the progress of what has already been completed here: http://projectfeather.sitefinity.com/#/progress

Saturday, August 1, 2015

Upgrading to Windows 10 Pro from Windows Home Edition

After recently redeeming my free upgrade to Windows 10, I was left with Windows 10 Home Edition on several of my computers. As a developer, I minimally wanted Windows 10 Pro on at least my development computers, so I checked to see if there was an option to do a "Windows Anytime Upgrade" as was previously available with earlier editions of Windows (such as Windows Vista).

Unfortunately, I was not able to find any such links in the Windows Start Menu nor any references on the web as to how to accomplish this!

Fortunately, though the Windows Media Creation Tool allows you to create bootable USB media or ISO images for editions of Windows 10 that you may not even own (such as Windows 10 Pro)! Therefore, I decided to create an ISO image for Windows 10 Pro and launch the setup executable to begin the process of trying to upgrade to Windows 10 Pro: