Thursday, June 30, 2016

The requested resource does not support http method 'POST'

I was recently working on developing and testing my ASP.NET Web API layer when I suddenly encountered the following error message while attempting to perform a Post to my Web API controller:

{"message":"The requested resource does not support http method 'POST'."}

Of course, I had designed everything exactly as expected, so I was perplexed as to why this was not working.

I ended up looking at this article, but this did not offer any real clue as to why my system was not working since I had already decorated my Web API methods with the appropriate attributes: http://www.dontpaniclabs.com/blog/post/2013/01/23/that-pesky-requested-resource-does-not-support-http-method-post-error-when-using-mvc-web-api/

Finally, I decided to take a look at my routing configuration in my WebApiConfig.cs file which provided the following default route:


Well, if you look at the default routing rule, you will see that it requires an {action} value in the Url! Therefore, in order to get this to work correctly, I would have to specify a Url such as this instead: http://localhost/api/mymethod/post
Of course, I wanted to avoid using this style of routing in my Web API service layer, since this style is not very "RESTful" so I could either use Attribute-based routing or simply change my WebApiConfig routing to the following:

Once I changed this default routing, I was able to get my Web API Service Layer to behave correctly without this error message!

Get XML Comments Path for documenting ASP.NET Web API

One common tasks for many projects is documenting their ASP.NET Web API projects using the Xml Comments in the project.

However, the default code in Web API does not know how to locate the Xml Comments file, so you have to write this custom code yourself!

You can easily add this code to your Web API by using the following code snippet:


Filing a Support Request in the Windows Azure Portal

If you ever run into a problem while working with Windows Azure, chances are that you will need to file a support request at some point in time.

If you are managing a Virtual Machine, you can click on the Settings for your Virtual Machine and then click on "New support request"


If you are using  your default MSDN benefits, chances are that you will not have any support plan available or associated with your Azure account.

If you are very fortunate, then you may have been selected to participate in the Azure Basic Support option: https://azure.microsoft.com/en-us/support/plans/basic/.  As Microsoft would have it, this Basic Support option is by INVITATION ONLY.



However, if you have some other Microsoft benefits (such as being a member of the Microsoft Partner Network), you can associate your Partner Contract ID with your Azure subscription:


Once you have your Contract linked, you should be able to then file an Azure Support Request.





Getting the Publish Settings file for Windows Azure

If you are connecting to Windows Azure with PowerShell, then you can either set up an account in Azure Active Directory in order to be able to log into your Azure account as "Work or school account" or you can revert to using a Publish Settings file!

While this was relatively easy to find in the Classic Azure Portal, this is not so easy to find in the new Azure Portal.

Fortunately, you can still download the Publish Settings file using PowerShell!

The PowerShell script will ultimately send you to this Url to download your Publish Settings file once you log into the system: https://manage.windowsazure.com/publishsettings/index?client=powershell

So, if you are already logged into your Azure account in your web browser, you may be able to download the Publish Settings file directly.

If you still want to know how to do this through PowerShell, here is the PowerShell script for your review:


Wednesday, June 29, 2016

Excluding files using Robocopy and PowerShell

When I want to do web deployments as part of my continuous integration build process, I often need to exclude certain files such as the Web.config from being deployed to my staging or QA environments.

Therefore, I use Robocopy and PowerShell to accomplish this.

Using this simple little PowerShell script, you can use Robocopy to exclude files from your deployments as well:

Working with .gitignore files in Visual Studio

If you work with the .gitignore file in Visual Studio, you will notice that the Visual Studio IDE leaves a lot to be desired when it comes to ignoring files to add to the .gitignore file.

For example, you can only ignore items when they are first added to Visual Studio:


Of course, if you ever want to ignore additional files from Git AFTER  they have been added to the project/solution, Visual Studio offers no built-in method to accomplish this within the IDE!

Fortunately, the famous developer Mads Kristensen provides the .ignore Visual Studio Extension!  https://visualstudiogallery.msdn.microsoft.com/d0eba56d-603b-45ab-a680-edfda585f7f3

After installing this extension, when you then open the .gitignore file in Visual Studio, you will get nice syntax highlighting as follows:



Some of the nice features that it provides is browsing of directory paths in the .gitignore file:


It even provides path information to indicate when file paths that are listed in the .gitignore file do not exist:




Supposedly the grayed out text in the file points to invalid file paths, but, when I point to file paths that DO exist, in some cases, I end up with this instead:


So while this extension fills in a large number of gaps missed by Visual Studio, it has several limitations of its own.  Nevertheless, it is a handy tool to have around when working with your .gitignore files!

Performing a TeamCity Project Restore

In recent releases of Jetbrains TeamCity, a "Projects Import" feature has been provided which allows you to restore most of your data from one TeamCity installation to another.

The process requires you to first take a Backup of the TeamCity installation which is then stored as a .zip file in the TeamCityData\backup directory.

I recently had to migrate TeamCity from one server to another, so I decided to try out this feature for myself.

When you first get to the Projects Import screen, you are informed that you need to place the backup .zip file in the TeamCityData\import directory (which did not already exist on the system).  Consequently, I manually created the import directory and placed my most recent backup file into it.  After refreshing the screen, TeamCity readily found my backup file:






After I clicked on "Configure Import Scope", I was prompted for the information that I needed to import into TeamCity:





After selecting "Start Import", my import process started and my project was restored!





I looked over my project build configurations and everything seemed in order just as it was configured on my earlier server.

Of course, I quickly discovered that the reason that this feature is called "Projects Import" is because it is not a full TeamCity restoration!

I discovered several items that I had configured on my other TeamCity server to be missing:


  • Email Notifier
  • Notification Rules
  • NuGet
  • Plugins such as Octopus Deploy and Visual Studio Online Work Items
  • Issue Tracking integration dependent on my Visual Studio Online Work Items plugin
Therefore, while this is not a comprehensive restoration of a TeamCity installation from one server to another, it does a fairly good job of retaining all of the information needed for a project to perform continuous integration builds!!

New authentication methods in SQL Server 2016

I recently set up and configured a SQL Server 2016 instance on a virtual machine and when I logged into the system for the first time, I encountered a welcome change to the authentication screen!






As you can see from the above image, SQL Server 2016 has now added support for "Active Directory Password Authentication" as well as "Active Directory Integrated Authentication"!

If you can read this article, you can get some more details on these 2 new types of authentication mechanisms: https://msdn.microsoft.com/en-us/library/ms189721.aspx

If you read through the article, you can see that both of these authentication mechanisms are targeted towards authenticating against Azure Active Directory!

For more information on connecting to SQL Server using Azure Active Directory, you can check out this article: https://azure.microsoft.com/en-us/documentation/articles/sql-database-aad-authentication/

Installing Microsoft Antimalware for Windows Azure Virtual Machines

One of the many changes that came about as part of the switch from the Azure Classic Portal to the new Azure Portal was the way in which you install Microsoft Antimalware for your Windows Azure Virtual Machines.

In the past, you would simply choose "Microsoft Antimalware" as part of the wizard when you are setting up your virtual machine for the first time.  Unfortunately, that practice also did not allow you to go back and set it up later once the virtual machine was created.

While Microsoft has made it easier to turn on now at a later point in time, since it is no longer part of the initial creation process of the Windows Azure VM and it is disabled by default, it is also easier to forget!

Fortunately, installing Microsoft Antimalware after the fact is relatively simple.

First click on the Settings for your virtual machine:




In the Settings menu, you should see a menu option for "Extensions".  Once you click on that you should get a list of the currently installed extensions.  In the toolbar for that new screen, you should be able to click on the "Add" button to get a list of additional extensions to install:




In that list, you will find the listing for "Microsoft Antimalware".  You can click on it to open another screen for configuring Antimalware and creating it on your Windows Azure VM:



Once you read through the details screen, you can click on the "Create" button.  This will then provide you a final screen to configure the settings for Microsoft Antimalware:



Once you have configured all of the rules for running Microsoft Antimalware, you can click on the OK button to set it up on your Windows Azure VM.  It should now show up in the list of installed extensions for your VM listed as "IaaSAntimalware":


Finding the Team Project when logging into Visual Studio Online/Team Foundation Server the 1st time

A question that I get frequently asked by many users who are using Team Foundation Server/Visual Studio Online for the 1st time, is where are the Team Projects?

Well, when you 1st log into the web-based dashboard of Team Foundation Server or Visual Studio Online, you will notice that there are no projects listed anywhere on the home page dashboard!

As Microsoft has it currently, even though you are assigned to a project, you still have to manually browse to that project the 1st time you log into the system as follows:


Under "Recent projects & teams", you will have to click on the link for "Browse".  This will then open a Browse Server dialog which will allow you to choose from the respective projects to which you have been assigned:


Once you select the appropriate project, these projects will not appear beneath "Recent projects & teams":


Next, you can click on the name of one of your Team Projects to navigate to that project:




This will take you to YET ANOTHER Dashboard from which you can access basic information about your Team Project.  For most users, though, you will want to go straight to the Work Items which is in the top left-hand navigation appropriately titled "Work":


Once you access that area, you will be able to view all of your Work Items such as Epics, Features, and Product Backlog Items!

Tuesday, June 28, 2016

Checking resource and cost utilization in the Windows Azure Portal

If you want to monitor how many resources you are utilizing as well as how much you are spending in Windows Azure, you can check this very easily!

Once you log into the Windows Azure Portal, on the left hand navigation, you will see a link for Subscriptions:


You can then click on the name of your Windows Azure Subscription to view the resource usage:



That is all there is to it!!  Pretty simple, huh??

Premium vs. Standard Disk Storage in Windows Azure Virtual Machines

If you are building Virtual Machines in Windows Azure, you will probably need to add additional disk storage at some point in time as your needs grow.

However, you should be aware that Windows Azure Disk Storage has a different pricing model for Premium vs. Standard Disk Storage: https://azure.microsoft.com/en-us/pricing/details/storage/

You will immediately discover that Premium Disk Storage costs SIGNIFICANTLY more than Standard Disk Storage so it is important to make sure you choose the right type of Disk Storage for your needs.

You can follow the simple steps below to add a new disk to your Windows Azure virtual machine:


  1. Select your virtual machine
  2. Click on the Settings for your virtual machine
  3. In the Settings menu, click on Disks
  4. At the top of the Disks menu, you will see an icon for "Attach new"
  5. Click on the Attach new icon
  6. You will now be prompted for information regarding your new Disk.  
  7. When you choose your disk, Windows Azure has now DEFAULTED the Type to Premium.  Therefore, you will want to change the selection to Standard
  8. When you choose a Standard disk, the default size will be 1023 GB (approx. 1 TB).  You can then configure the location settings for your disk which will specify the storage account to use.
  9. Once you click OK, your new disk will be added to your virtual machine!






Online Kendo UI scratchpad

If you are just learning Kendo UI and want to experiment with how Kendo UI works without installing it on your local machine, fortunately Telerik has provided just such an environment for you to accomplish that!

Kendo UI Dojo
http://dojo.telerik.com/

In this browser-based environment, you can add whatever Kendo UI code you need to experiment with the various controls and run them directly through the browser!

Of course, the base code provided does not help much with getting started with any sophisticated Kendo UI control examples, so it is best to start with a slightly more complex starting point such as this one: http://dojo.telerik.com/EFABI

The above Kendo UI examples utilizes the Kendo UI Grid control and does some basic customization and styling of the Kendo UI grid that allows you to better understand how the Kendo UI grid needs to be modified for your own tweaks and customizations!

Telerik RadControls for ASP.NET AJAX vs. Telerik Kendo UI controls for ASP.NET MVC

If you have developed with both ASP.NET Web Forms and ASP.NET MVC technology, then you might be familiar with both the Telerik RadControls for ASP.NET AJAX as well as the Telerik Kendo UI controls for ASP.NET MVC.

Also, if you have worked with both of these technologies, you will also know that ASP.NET Web Forms has been a technology that has been around for the last 14+ years while the 1st release of ASP.NET MVC was released only approximately 7 years ago.  Kendo UI itself was only released in 2011!

Just to further clarify the disparity in years between these 2 products, you could use an analogy of children.  The Telerik RadControls would be a teenager in High School while the Kendo UI controls would still be a toddler in Kindergarten!!

Therefore, as you can probably already guess, the suite of controls for ASP.NET Web Forms will be far more advanced and sophisticated than the suite of controls available for ASP.NET MVC!

If you take a quick look at the Telerik RadControls Demo site, you will immediately notice the immense amount of functionality provided by the Telerik RadGrid itself: http://demos.telerik.com/aspnet-ajax/grid/examples/overview/defaultcs.aspx

Now when you compare this functionality to the Kendo UI Grid, you will find the features and functionality available to the Kendo UI Grid comparably much, much, much smaller: http://demos.telerik.com/aspnet-mvc/grid/index

So what does that mean for developers using ASP.NET MVC and Kendo UI controls?  Ultimately, it means that you will still have to develop a TON of custom functionality on your own either through extending these existing controls or through using JavaScript frameworks such as AngularJS and jQuery.

Alternatively, if your organization is open to mixing and matching functionality in your application, you can consider adopting a One ASP.NET approach and be able to include ASP.NET MVC in your application alongside ASP.NET Web Forms.

If you are able to adopt this approach, this allows you to get the best of both worlds in being able to leverage the extremely rich functionality of the Telerik RadControls for ASP.NET AJAX in your ASP.NET Web Forms pages as well as the very lightweight Telerik Kendo UI controls in your ASP.NET MVC Views!!

Telerik Online Demos missing complete code for code samples

I frequently use the Telerik controls for my development and therefore I heavily rely on the Telerik Demo site to figure out how to accomplish a wide variety of development tasks when working with these controls.

For example, in the Kendo UI Grid Hierarchy example (http://demos.telerik.com/aspnet-mvc/grid/hierarchy), you will find code in the HierarchyController.cs file, but dependent code such as GetEmployees() or GetOrders() will not be found in the online code sample!!

So where do you go to look for that missing code?

Well, at first, I thought that I would look at the Demos that I installed locally on my machine only to be disappointed that the demo site installed locally on my machine also suffered from the same problem!

Therefore, I ended up digging into the actual Kendo UI MVC Examples folder installed locally on my file system to pull up the Visual Studio project and dig through all of the dependent code.

On my system, this was installed at the following location:

C:\Program Files (x86)\Telerik\UI for ASP.NET MVC Q2 2016\wrappers\aspnetmvc\Examples\VS2015\Kendo.Mvc.Examples

Of course, looking in the wrappers directory was not readily obvious since I expected it to be in a directory called samples or examples or something like that at the very top level of the installation!

In any case, once you know where to find all of the necessary example code to use, you can readily apply it to your own application!

Run Visual Studio as Administrator by default

If you work with Visual Studio and your local IIS instance, you may soon discover that you are unable to load any projects in your solution that are bound to your local IIS instance!

This is because Visual Studio is set to default to using IIS Express which requires lower privileges than projects bound to your local IIS instance.

In order to resolve this problem, you simply need to right-click on your Visual Studio icon and select "Run as administrator" each time before you launch the application.

However, if you use Visual Studio every day, you can see how performing this operation over and over again can be tedious and annoying.

But if you know this handy tip, you can launch Visual Studio with Administrative privileges by default each time!

For this example, I am using Visual Studio 2015, but this can be equally applied to any older version of Visual Studio such as Visual Studio 2013 as well:


  1. Since this operation cannot be performed from the Metro Windows Start menu in Windows 8.1, I would suggest that you pin your Visual Studio icon to the Taskbar.
  2. Now, right click on the pinned Visual Studio icon to launch the popup context menu.
  3. From the popup context menu, select "Visual Studio 2015" (or the name of any earlier instance of Visual Studio)
  4. Right-click once again on the name of "Visual Studio 2015" to get yet another popup context menu
  5. Now, select "Properties" from that subsequent popup context menu
  6. From the new dialog that displays, make sure the "Shortcut" tab is selected and click on the "Advanced..." button
  7. On that screen, you will see an option to select a checkbox for "Run as administrator"
  8. Select that checkbox and click OK
  9. Click OK one more time to close out of the Shortcut dialog
  10. Now when you launch Visual Studio, it will launch under Administrative privileges by default!





Visual Studio "Clean" operation does not clean up renamed assemblies

I recently ran into a problem whereby I was re-organizing, renaming and re-structuring my projects in my solution and I started receiving runtime errors in my application even though my solution compiled just fine!

Looking at the error message, it appeared that the names of the assemblies were outdated and were still somehow being referenced in my project!

Naturally, I checked all of my project references and everything was in order.  I also ran a "Clean" operation in Visual Studio to clean out all of my old assemblies from their respective bin directories.

However, I continued to receive these runtime error messages!

Since this issue still persisted, I decided to do a bit more investigation directly into the bin directories of all of my projects.

Sure enough, my old assemblies before the rename process still existed in their respective bin directories!

After having to manually go through each and every one of my bin directories in my project and manually deleting them (I may write a PowerShell script in the future to accomplish this), I recompiled my solution and everything ran perfectly!

Therefore, a word to the wise, don't completely rely on the "Clean" operation in Visual Studio to do all the cleanup tasks for you!!

Sharing Telerik Kendo UI assemblies with your development team

One of the problem with using many 3rd party products such as Kendo UI in the past was ensuring that EACH and EVERY developer had the same version of the product installed on their machines!!

If you can just imagine dealing with the administration nightmares with such a product that has multiple releases and hotfixes several times a year!!

Well, thankfully, the Telerik development team has provided a nice resolution to this problem of the past through our all-too-familiar process of NuGet!!

Yes, you heard correctly!  You can now distribute your Telerik references such as Kendo UI through pre-built NuGet packages!  Woo hoo!

All you have to do is set up your own NuGet Server on your own network by following an article such as this one: https://docs.nuget.org/create/hosting-your-own-nuget-feeds

Then, once that is complete, you can go into your Telerik account and download the appropriate NuGet packages that are available for your various products and drop them onto your NuGet server packages directory.




Then once that is complete, you will get a dialog similar to the following when you browse your NuGet server for packages:



You can get more details about setting up Telerik references on your NuGet server here: http://www.telerik.com/blogs/power-your-projects-with-telerik---now-with-the-convenience-of-nuget


Monday, June 27, 2016

.NET Core Released!

After a very long time waiting for the final release of .NET Core, Microsoft has finally released .NET Core to RTM!

You can download the final RTM release of .NET Core here: https://www.microsoft.com/net/core#windows


Visual Studio 2015 Update 3 Released!

Visual Studio 2015 Update 3 was released to address a number of performance and memory issues.

You can download Visual Studio 2015 Update 3 from here: https://www.visualstudio.com/news/releasenotes/vs2015-update3-vs

Integrating TeamCity with Visual Studio Online Work Items

If you want to integrate Jetbrains TeamCity with Visual Studio Online Work Items, unfortunately, TeamCity does not provide this functionality out-of-the-box.

However, you can still link these 2 systems together using a TeamCity plugin as outlined in this article: https://blog.jetbrains.com/teamcity/2014/11/integrating-teamcity-and-visual-studio-online-work-items/

You can obtain the Visual Studio Online Work Items plugin from here: https://confluence.jetbrains.com/display/TW/Visual+Studio+Online+Work+Items

Reading the article is a bit confusing as to where to obtain the plugin, so I am providing the direct link here: https://teamcity.jetbrains.com/project.html?projectId=TeamCityPluginsByJetBrains_VisualStudioOnlineIssueTrackin

You then have to click on the link for "Artifacts" and then download the .zip file appropriate to your version of TeamCity.

 Once you upload the Visual Studio Online plugin and re-start your TeamCity Server and TeamCity Build Agent, you should see a screen similar to the following:




Then, once you go into your Project and select Issue Trackers, you should now have an option for Visual Studio Team Services:


Next, you can simply add your settings for Visual Studio Online:



You should then fill out the screen with information similar to the following:


Finally, you can test the connection to make sure all of your settings are valid and you should get a result similar to the following:



Finally, your newly configured Issue Tracker with Visual Studio Online Work Items should show up in TeamCity like this:


Friday, June 24, 2016

Windows Live Writer no longer works with Blogger!

I have been using Windows Live Writer for a very long time to manage my code snippets on my blog and when I logged into Windows Live Writer, I discovered that I could no longer log into Blogger!





It also seems that this problem has been reported by a large number of users from more than 1 year ago: http://answers.microsoft.com/en-us/windowslive/forum/writer-program/windows-live-writer-wont-connect-to-blogger/f3ae8ae5-f013-477b-b262-399430d29e28?auth=1

https://plus.google.com/u/0/+RickDoyle/posts/GUPJcu5sZHo

After discovering that Windows Live Writer is no longer actively maintained by Microsoft (the last release version was back in 2012), I started frantically searching for other code snippet tools that would work with Blogger.

One of the ones that I discovered was hilite.me (http://hilite.me/) as well as SyntaxHighlighter (http://alexgorbatchev.com/SyntaxHighlighter/integration.html), however, the sharing and formatting of the code snippets was not as nice as some other syntax highlighting tools such as Crayon Syntax Highlighter for WordPress (https://wordpress.org/plugins/crayon-syntax-highlighter/)

Fortunately, though, I finally came upon GitHub Gist! (https://gist.github.com)

I can easily embed a snippet of HTML that consequently embeds some JavaScript into the page which directly links to the code snippet on GitHub!

Even though I cannot directly preview the code snippet while editing my blog on Blogger, GitHub Gist offers an additional convenience allowing users to directly copy or download my code snippets for their own use!

This offers an additional level of code sharing with my users that I do not readily get with other tools, so I have decided to switch all of my new code snippets and samples over to GitHub Gist!!

Creating Work Items in Team Foundation Server/Visual Studio Online

I have been working with Team Foundation Server Work Items for quite some time and one of the things that has always been frustrating to me has been the disparity in web-based work item functionality between different views in Team Foundation Server.

For example, if you go into the Home Dashboard of Team Foundation Server, you will be presented with the following view:






This Dashboard view allows you to readily any type of Work Item such as a Bug, Epic, Feature, Impediment, Product Backlog Item, Task or Test Case.

However, as soon as I switch to the Work section of Team Foundation Server, I am presented with these 2 views instead!


In these views, I can only add a Feature, Product Backlog Item or a Bug! 


There is no default view in the Work section that allows me to easily add any of these other Work Items: Epic, Impediment, Task or Test Case.  Instead, if I want to add any of these other Work Item types, I have to add a new Link to an existing Work Item and then create these other types of Work Items from there:





This is especially annoying if you want to create a parent record directly such as an Epic which will include multiple Product Backlog Items or Features.  But, unfortunately, the Epic Work Item type cannot be created directly from the Work section of Team Foundation Server and must either be done this way or through the Home Dashboard!

Of course, if you are managing Work Items through Visual Studio Team Explorer, all Work Item types are immediately available to you!






Hopefully, Microsoft will correct these web-based Work Item usability problems in a future release of Team Foundation Server/Visual Studio Online, but for now, the best solution is to work through the web-based Home Dashboard!!