Updating Visual Studio 2013 default Class.cs template

This is a Jeanious Note, a note I keep for myself and share with the Internet. I hope this helps someone else too. :)

A few days ago I was frustrated after a code review revealed that I had again forgotten to put the copyright information at the top of a new cs file.  I knew there had to be a way to update the the VS2013 template for a new class.cs file so that I can have the copyright just be there when I create a new class.cs.  After some searching on the internet I couldn’t find the exact solution for modifying a VS2013 template.  Ok I could find the location of the Class.cs template for VS 2013 but there was information for the location of the Class.cs template for VS2010 & VS2012.  Updating the VS2013 Class.cs template should be much different than in previous versions of Visual Studio.  As it turns out as of VS 2012 you can edit the Class.cs and not have to deal with the all the extra steps in pervious version of Visual Studio.  The “hard” part was that non of the posts I found had the location of the Class.cs template for a VS2013. Here’s the location if you use the default install location:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.cs

navigatIng to files in Visual Studio 2013

This is a Jeanious Note, a note I keep for myself and share with the Internet. I hope this helps someone else too. :)

Situation: I just joined a new team that has existing code. I have navigated to a file by using F12 to find where a method is defined. But now I don’t know the location (folder and project) the current file that is open.  The image below say I want to find where HomeController.cs is located.  I have two options.  The first to to click the icon to “Sync with Active Document” which I have circled in Red.


By clicking the “Sync with Active Document” icon can now see that the HomeController.cs is located in the Controllers folder.


But what I really want is to always see the location of the currently active document without having to click the icon every time.  What needs to be done is to go to tools->options. under “Projects and Solutions” check the box that says “Track Active Item in Solution Explorer”


That’s it.

Getting Intellisense back

This is a Jeanious Note, a note I keep for myself and share with the Internet. I hope this helps someone else too. :)

For those time when I have a trial expire or I uninstall an add on to Visual Studio and I “lose” the IntelliSense that ships with Visual Studio all I need to do is reset Visual Studio back to the original settings.

Tools->Import and Export Settings…


Select Reset all Settings

Now just walk through the wizard and when you are done the IntelliSense that ships with Visual Studio will be back.


I have been working on a Windows Azure project that was started using the Windows Azure 2.0 SDK. After the upgrading to the Windows Azure 2.1 SDK we noticed that the Worker role was no longer work. Since development was being done only on the web role a decision was made to wait to look into why the worker role stopped working.

The project was recently upgraded to Windows Azure 2.2 SDK. It was time to figure out why the worker role stopped working. The problem was with the references were not getting updated and config files were referencing the the wrong version number. The simplest way to ensure that all the references were updated properly is to use Nuget to install and update Windows Azure Storage, Configuration, and Diagnostics.

That made the worker role start working again. While I was testing the system to make sure that web role could still get message to the worker role via the queue it quickly became obvious that something was still wrong.

Time to roll up my sleeves and figure out what was causing the web role to throw an error. The error I was getting is a FileLoadException when I try to get the cloud storage account.

Error message:



Let’s look at the details for this exception:


Notice that the error states that ‘Microsoft.WindowsAzure.Diagnostics’ version couldn’t be found.  This is a problem as we as we are upgrading to version

I proceeded to update the WindowsAzure Diagnostics to using Nuget. But I continue to get the same/similar error message. OK so what didn’t Nuget update for me? By doing a search on all files in my solution for ‘’ I discovered the that Microsoft.WindowsAzure.Diagnostics was referenced with the wrong version number in the Web Roles web.config file.


In the web role’s web.config file change the version number to




<add type=”Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ name=”AzureDiagnostics”>

<filter type=”” />





Deploying a SQL Database to an Azure SQL Database

My wonderful husband was explain to me how to set up a website so that it could be deployed to the Azure.  At the time I was watching him do the work so when it came time for me to set up my own app to deploy to Azure I couldn’t remember all the steps that need to be done BUT I did remember that he had a course on Pluralsight that should be able to tell me how to do migrate my website to Azure.

Migrating your SQL database to Azure SQL

Things that arent’ supported:

  • Cross Database joins
    • Fix would be to modify the code to handle this
  • All tables need to have a Primary key
  • Some feature aren’t supported
    • Such as column in encryption.  you can fix this by using an ORM like Entity Framework and set the encryption via code (attribute?)
  • Get a list of unsupported feature in Azure SQL http://msdn.microsoft.com/en-us/library/windowsazure/ee336253.aspx
  • Updates that spans multiple resources
    • You will have to write custom code to handle this.

SQL Migration tools

SQLAzureMW (SQL database migration wizard): http://sqlazuremw.codeplex.com/

Redgate Toolbelt: http://www.red-gate.com/products/sql-development/sql-toolbelt/



Scott Seely’s Migrating Internet Applications to Azure

XSS – Cross Site scripting

Reflect XSS

In the querry string simply add something like msg=<script>alert(‘XSS’)<script>

Persistent XSS

A script that has been injected into the database.  An example would be to  add the script to a comment field.  Thus everytime the list of comments is display the scirpt is run.  OR it could be embedded in an image file. New browsers won’t display the image but IE6 will.

DOM Based + JSON + JQuery



Adam Tuliper’s Hack-proofing Your ASP.NET Web Applications

Output caching & caching profiles

To speed up page loading you may want to user the [OutputCache] attribute.  You must set a duration to cache the output and that value is in seconds.  So your attribute would look like

   [OutputCache(Duration = 60 )]

That’s good but what if you have data that is being paged? each page is cached which makes for a quicker load when you click the next and previous button.  What if the user edits the query string to go to a specific page?  you will get the cached data but not the rest of the UI.  To fix this we can add the following:

   [OutputCache(Duration = 60, VaryByHeader = “X-Requested-With” )]

But the page is being cached in the browser so you will need to add :

   [OutputCache(Duration = 60, VaryByHeader = “X-Requested-With”, Location = OutputCacheLocation.Server )]

You best bet is to create a separate controller action for Ajax.

Caching Profiles

So now your site is live and you are still having performance issue.  Since the site is live you really don’t want to have to change the code, recompile and then redeploy the site to increase the performance.  You also don’t want to spend a lot of time finding every place where you have done an OutputCache and tweak the duration or other parameters (I’ll just use duration for my example).  Cache profiles allow us to save the duration in the Web.config where we can make a change and see the results without recompiling and redeploying the site.  So how do we do this?  First we change the OutputCache attribute to look like this:



Then in web.config we add the following to the system.web section

      <add name=”Aggressive” duration=”300″/>

<add name=”Mild” duration=”10″/>



Scott Allen’s Building Applications with ASP.NET MVC 4