Wednesday, July 29, 2015

Upgrading to Windows 10 - First Impression

Normally when an OS is first released, I usually wait quite some time before I decide to upgrade my older OSes to it and instead install it on a virtual machine before upgrading my main computers.

However, I have been using Preview builds of Windows 10 for quite some time on my virtual machines and was very happy overall with the usability and performance of the new OS.

Therefore, I decided to give it a try and see what it would be like to upgrade to Windows 10 from my existing Windows 8.1 system.

First of all, I did not want to try going the Windows Update route since that could potentially disastrous, so I decided to go the Media Creation route instead: http://windows.microsoft.com/en-us/windows-10/media-creation-tool-install

When I first ran the Media Creation Tool (for my 64-bit OS), I was given the option of either upgrading my current PC or downloading the media to upgrade another PC. 

I first created the media and installed it onto a USB Drive as a safety measure and then ran the tool again to upgrade my existing PC.

The whole process took around 1.5 hours on my existing Windows 8.1 PC which included downloading and upgrading my OS (over my 75 Mbps connection). 

As part of the upgrade process, I was notified that I would need to uninstall Mcafee VirusScan Enterprise 8.8i since it was not compatible with Windows 10.  Unfortunately, an update for Mcafee VirusScan Enterprise 8.8i that fully supports Windows 10 will not be available until the end of August, but I also had a subscription to Mcafee LiveSafe, so I decided to go ahead and uninstall Mcafee VirusScan Enterprise 8.8i since I was getting very sick and tired of using Windows 8.1 anyway.

Well, after I uninstalled Mcafee VirusScan Enterprise 8.8i, the entire upgrade process went very smoothly!

I did not run into any hiccups or halts or breaks during the entire upgrade process.  All of my applications and files were all wonderfully preserved.

Of course, Internet Explorer 11 was replaced with Microsoft's new Edge browser and best of all, the new Windows 10 OS ran much faster than my previously installed Windows 8.1 OS with the tremendous number of installed updates!

So far, I am very impressed with the new Windows 10 and it is definitely a welcome upgrade to using Windows 8.1.  I haven't actively used Windows 7 for several years, but I prefer it over the older Windows 7 especially because the file explorer copies are just as fast (if not faster) than when I was using Windows 8.1 for frequent file transfers across my network.

I am looking forward to upgrading all of the computers on my home network to Windows 10 over the next few days so that everyone in my family can benefit from this great new OS!!

Upgrading your existing Windows 7/8/8.1 system to Windows 10

You can download a Media Creation Tool to download and upgrade your Windows 7, Windows 8 or Windows 8.1 system to Windows 10.

You can download the Media Creation Tool from here: http://www.microsoft.com/en-us/software-download/windows10?OCID=WIP_r_Win10_Body_AddPC

For instructions on how to use the Media Creation Tool, you can check out this article: http://windows.microsoft.com/en-us/windows-10/media-creation-tool-install?ocid=ms_wol_win10

Mcafee VirusScan Enterprise for Windows 10

If you are currently using Mcafee VirusScan Enterprise v. 8.8i for your Windows 7 or Windows 8/8.1 operating systems, unfortunately, Mcafee has not yet released a version to support Windows 10 that was just released today.

According to this Mcafee Knowledge Center article, you can expect full support for Windows 10 sometime towards the end of August with the release of Patch 6: https://kc.mcafee.com/corporate/index?page=content&id=kb51111

Windows 10 released on MSDN!

You can now download Windows 10 Enterprise and Windows 10 Enterprise LTSB from MSDN!!

In addition, if you are not familiar with LTSB, it is the Long Term Servicing Branch of Windows 10 which supposedly does not ship with the Microsoft Edge browser and continues to ship with Internet Explorer 11.  It will also not receive new feature updates to the platform, unlike the CB (Current Branch) version of Windows 10.

You can read more about the differences between the LTSB and the CB branch versions of Windows 10 from here: http://windowsitpro.com/windows-10/understanding-long-term-servicing-branch-and-current-branch-windows-10

Tuesday, July 28, 2015

Using Web.configuration Transforms in your ASP.NET Web Application Projects

If you are learning about Web.configuration transforms or are already familiar with Web.config transformations, you may be frustrated by the fact that there is limited Intellisense for Web.config transforms.  That is to say, when selecting attribute values for a Web.config transformation, you have to either know the value for the Web.config transform attribute or you have to look it up!

Well, fortunately, there is an MSDN reference for Web.config transformation syntax here: https://msdn.microsoft.com/en-us/library/dd465326%28v=vs.110%29.aspx

In addition, you can test out and preview your Web.config transformations by using the Slow Cheetah Visual Studio Extension:

Slow Cheetah for Visual Studio 2013: https://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5

Slow Cheetah for Visual Studio 2015: https://visualstudiogallery.msdn.microsoft.com/05bb50e3-c971-4613-9379-acae2cfe6f9e

Upgrading to Sitefinity v. 8.1

If you want to upgrade to Sitefinity v. 8.1 which now supports ASP.NET MVC 5 and .NET Framework v. 4.5, your original Sitefinity Web Application Project file will not automatically be upgraded with the correct project references. 

Therefore, you will have to correct and update these yourself.

The new references that you will have to update in your project for the ASP.NET MVC 5 Assemblies are the following:

  • System.Web.Mvc
  • System.Web.Helpers
  • System.Web.Razor
  • System.Web.WebPages
  • System.Web.WebPages.Razor
  • System.Web.WebPages.Deployment
 In addition, if you are using any Sitefinity MVC Widgets in your project, you will need to make sure you have a reference to this assembly:

  • Telerik.Sitefinity.Mvc

 Once you have fixed up these assembly project references, you should now be able to successfully compile your project for Sitefinity v. 8.1!!

Monday, July 27, 2015

Setting up OWIN for ASP.NET Web API from scratch

If you start out with either an ASP.NET MVC or ASP.NET Web API project using the option "No Authentication", you may notice that you will not get support for OWIN included in your project by default!

Therefore, you will have to add OWIN functionality back into your application step-by-step.

You can use these articles as starting points, but they are missing several pieces of information for hosting ASP.NET Web API in a standard Web Host:

http://www.asp.net/aspnet/overview/owin-and-katana/getting-started-with-owin-and-katana

http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api

Below are the steps that are needed to accomplish this by adding the appropriate NuGet packages:

  •  Microsoft.AspNet.WebApi.Owin
  • Microsoft.Owin.Security.OAuth
  • Microsoft.Owin.Security.Jwt
  • Microsoft.AspNet.WebApi.Cors
  • Microsoft.Owin.Host.SystemWeb
















Affordable ASP.NET Hosting Providers that support SQL Server 2014

As many developers know, SQL Server 2012 is already old news compared to SQL Server 2014.  With the upcoming release of SQL Server 2016, I wanted to make sure any hosting provider I choose at least supports SQL Server 2014 (hopefully in combination with Windows Server 2012 R2).

Unfortunately, many providers have not updated from SQL Server 2012 to offer SQL Server 2014 support yet, therefore, I set out to find some reliable ASP.NET Hosting Providers that support SQL Server 2014:

  1. http://www.winhost.com/windows-hosting-plans.aspx
  2. http://www.mywindowshosting.com/hosting_plans
  3. https://host4asp.net/
  4. http://www.smarterasp.net/hosting_plans
  5. http://www.hostbuddy.com/
  6. http://asphostportal.com/Windows-Shared-Hosting-Plans
  7. http://www.myasp.net/hosting_plans

Sunday, July 26, 2015

New version of Virtual CloneDrive released!

If you regularly mount ISO images on your computer (such as Windows ISO images), you will be glad to know that Slysoft, the makers of Virtual CloneDrive have recently released an update to support Windows 10!!

You can download the update from here: http://slysoft.com/en/virtual-clonedrive.html

Friday, July 24, 2015

Reading Claims from an OAuth Bearer Token

If you are using OWIN and OAuth in your ASP.NET Web API Web Application, like me, you may not know how to read back the Claims from the Bearer Token so that you can use them in your .NET Client.

Unfortunately, this information is incredibly difficult to find!!

Fortunately, there were a few code samples scattered over the web which allowed me to piece together a suitable solution.

Below is the code needed to read back the Claims from the resultant SecurityToken:
public static JwtSecurityToken GetJwtToken(string url, string userName, string password)

    {

        var pairs = new List<KeyValuePair<string, string>>

        {

            new KeyValuePair<string, string>("grant_type", "password"),

            new KeyValuePair<string, string>("username", userName),

            new KeyValuePair<string, string>("password", password)

        };

 

        var content = new FormUrlEncodedContent(pairs);

 

        using (var client = new HttpClient())

        {

            var response = client.PostAsync(url, content).Result;

            var result = response.Content.ReadAsStringAsync().Result;

 

            //Deserialize the JSON into a Dictionary<string, string>

            Dictionary<string, string> tokenDictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(result);

            var handler = new JwtSecurityTokenHandler();

            return handler.ReadToken(tokenDictionary["access_token"]) as JwtSecurityToken;

        }//using

    }

You will need to reference the following assemblies/NuGet packages to use this code on the client:
  1. System.IdentityModel
  2. Microsoft.Owin.Security.Jwt

Then, once you have returned the JwtSecurityToken, you simply need to write code such as the following to read back the Claims:

JwtSecurityToken token = OAuthClientWrapper.GetJwtToken(Url, userName, password);

 

Console.WriteLine("Claims in OAuth Bearer Access Token:");

 

foreach (var tokenClaim in token.Claims)

{

    Console.WriteLine(string.Format("{0}:{1}", tokenClaim.Type, tokenClaim.Value));

}//foreach

Netsparker Web Vulnerability Scanner

I was recently investigating Web Vulnerability Scanners and I came across Netsparker: https://www.netsparker.com/web-vulnerability-scanner/

I downloaded the demo and requested a fully functional trial version as well.

Overall, this is an excellent easy-to-use security scanning tool, and the demo version provides very useful information about the types of vulnerabilities that can be found in an ASP.NET Web Application.

Unfortunately, the demo site that they use (http://aspnet.testsparker.com) is an ASP.NET Web Forms Web Application and therefore will exhibit a different set of security vulnerabilities than the newer ASP.NET MVC Framework which many companies are using.

The lack of an ASP.NET MVC Demo Site significantly detracts from the usefulness of the demo for anyone evaluating this software for themselves (especially for modern ASP.NET development teams).

However, the friendly sales and support staff definitely makes up for this shortcoming to provide an excellent overall web security vulnerability scanner.

The Standard edition allows for 3 Websites (3 unique FQDNs) while the Professional edition allows for an unlimited number of websites (unlimited FQDNs).

The Standard edition will suit most organizations that have an autodeploy server and are not using host headers or subdomains to access the various different Web Applications.  Therefore, http://myserver.mycompany.com/App1 and http://myserver.mycompany.com/App2 and http://myserver.mycompany.com/App3 all still qualify as a single website whereas http://myapp1.mycompany.com and http://myapp2.mycompany.com would qualify as 2 separate websites.

If you are looking to incorporate Web Vulnerability testing int your development process, you should definitely take a look at Netsparker!!

Thursday, July 23, 2015

Creating Custom Action Filters in ASP.NET MVC

I recently had a need to create a custom Action Filter in ASP.NET MVC to perform some pre-processing before I executed my Controller Action Methods.

I followed these MSDN articles to get started creating my Custom Action Filter:

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

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

However, there was not a great deal of insight on how to pass values and use values in my ActionFilter as well as how to create a custom ViewResult (such as by adding errors to the ModelState Errors collection).

Therefore, I played around with some code until I was finally able to get this code sample working:

namespace MvcFilters
{
    public class CustomFilterAttribute : ActionFilterAttribute
    {
        public string ModuleName { get; set; }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            bool myValue = true;
            if (myValue)
            {
                base.OnActionExecuting(filterContext);
            }//if
            else
            {
                filterContext.Result = new CustomResult(this.ModuleName);
            }
            
        }
 
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);
        }
    }
 
 
   
}


namespace MvcFilters
{
    public class CustomResult : ViewResult
    {
        public CustomResult(string moduleName)
        {
            string strErrorMessage = string.Format("{0} cannot be used", moduleName);
            this.ViewData.ModelState.AddModelError("", strErrorMessage);
        }
 
        public override void ExecuteResult(ControllerContext context)
        {
            base.ExecuteResult(context);
        }
    }
}

Then, in order to use my ActionFilterAttribute in my ASP.NET MVC Controller, I simply decorate my ActionMethod in the following manner:



[HttpGet]
[CustomFilter(ModuleName ="Module1")]
public ActionResult Module1()
{
   return View();
}

 

That was all that was needed to get my Custom ASP.NET MVC ActionFilter to work and return my ModelState Error messages!!

Security vulnerability scanning with Burp Suite Professional

If you are using Burp Suite Professional to do your Security Vulnerability scans, you may notice that setting up your environment to simply run on a Windows OS is a rather tedious operation:  https://portswigger.net/burp/help/suite_gettingstarted.html

Well, I LOVE automation, so I decided to create PowerShell scripts to configure the most common operations needed to set up and use Burp Suite:

$regKey="HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"

 

$proxyServer = ""

$proxyAddress = "127.0.0.1";

$proxyPort = "8080";

 

$proxyServerToDefine = "$proxyAddress" + ":" + "$proxyPort";

 

Write-Host "Retrieve the proxy server ..."

Write-Host $proxyServerToDefine

 

$proxyServer = Get-ItemProperty -Path $regKey -Name ProxyServer -ErrorAction SilentlyContinue

 

Write-Host $proxyServer

 

if([string]::IsNullOrEmpty($proxyServer))

{

 

    Write-Host "Proxy is actually disabled"

 

    Set-ItemProperty -Path $regKey -Name ProxyEnable -Value 1

 

    Set-ItemProperty -Path $regKey -Name ProxyServer -Value $proxyServerToDefine

 

    Write-Host "Proxy is now enabled"

 

}#if

else

{

    Write-Host "Proxy is actually enabled"

 

    Set-ItemProperty -Path $regKey -Name ProxyEnable -Value 0

 

    Remove-ItemProperty -Path $regKey -Name ProxyServer

 

    Write-Host "Proxy is now disabled"

}#//else


$javaPath = "C:\Program Files\Java\jre1.8.0_51\bin\java.exe";

$burpPathPro = "C:\Burp\burpsuite_pro_v1.6.09.jar";

 

#java -jar -Xmx1024m /path/to/burp.jar

 

 

Clear-Host

$BurpCmd = @"

"
"$javaPath" -jar $burpPathPro";
"
@
Write-Host $BurpCmd

#Launch Burp Suite

& "$javaPath" -jar $burpPathPro

Licensing and Packaging Changes in Visual Studio 2015 and Team Foundation Server 2015

If you have not already checked out this blog post regarding the licensing changes to Visual Studio 2015 and Team Foundation Server 2015, you should definitely check it out! 

http://blogs.msdn.com/b/bharry/archive/2015/07/21/licensing-and-packaging-changes-for-tfs-2015.aspx

One of the most exciting tidbits of news in the blog article is that PowerPoint Storyboarding will be provided for FREE!!  How awesome is that???

I guess Microsoft REALLY DOES listen to the items posted on its UserVoice site!!!

Wednesday, July 22, 2015

Where is the TeamCity-Server.log Log File?

If you ever have to perform maintenance on your Jetbrains TeamCity installation, you may be prompted for an authentication token from your teamcity-server.log log file.

Well, fortunately, this log file is relatively easy to find!

It should be located in the logs directory of your TeamCity installation such as:

C:\TeamCity\logs\teamcity-server.log

Inside this log file, you should be able to find your authentication token needed to maintain your TeamCity installation (especially for TeamCity upgrades).

Tuesday, July 21, 2015

Bad news for Visual Studio 2015 Licensing

After the release of Visual Studio 2015 yesterday, I attempted to view the product key for Visual Studio 2015 in my MSDN subscription and I got the following error message:




I decided to contact Microsoft support about this and I got the following response:

I understand you need assistance in activating Visual Studio, and I will be more than happy to assist you on this.
This subscription does not offer a license for activating the software, as it can be activated using your Microsoft credentials.

Additionally, All licenses offered as a benefit through the Microsoft Partner Network are nonperpetual, so partners using their MSDN subscriptions will need to sign in at least once every 30 days with a valid Microsoft account (formerly called a Windows Live ID) that is associated to an active MSDN subscription, in order to activate their edition of Visual Studio 2015. 

Therefore, according to Microsoft support's response, everyone will need to have a Windows Live ID in order to activate their license of Visual Studio going forward!!  What a major bummer!  Hopefully, Microsoft will change their policy about this in the near future, but if you discover that you suddenly cannot view License Keys for Visual Studio in your MSDN subscription, now you will know why!!

If you would like to see Microsoft bring back Product Key licensing for Visual Studio 2015, you can vote for this UserVoice item here: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/8968879-bring-back-product-key-licensing-for-visual-studio

The NuGetPackage package did not load correctly

I just installed Visual Studio 2015 Enterprise RTM and attempted to open an existing Visual Studio 2013 solution that was using a NuGet.config file for NuGet Package Restores and was suddenly faced with this error message:






I found this article which seems to address this issue: http://stackoverflow.com/questions/31521438/vs2015-the-nugetpackage-package-did-not-load-correctly

I followed the steps outlined in the StackOverflow post as suggested by first uninstalling NuGet Package Manager from Visual Studio:


I then reinstalled NuGet Package Manager:






After restarting the IDE, I tried once again to "Manage NuGet packages", but unfortunately, I was not able to perform any NuGet operations whatsoever in the IDE including being able to open the "NuGet Package Manager Console"!

When I created a new project/solution in Visual Studio, as you can probably already guess, NuGet works perfectly!  It just fails to work correctly when opening/loading existing projects/solutions created in earlier versions of Visual Studio such as Visual Studio 2013.

Therefore, I decided to do a bit more investigation into what was different in Visual Studio 2015 vs. Visual Studio 2013 and I discovered this little section in the Visual Studio 2015 solution file:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1


By simply replacing this information in my existing Visual Studio 2013 solution files, I was able to get NuGet Package Manager to work once more!!


However, this victory was short lived since the NuGet problem re-occurred as soon as someone else edited the project file in Visual Studio 2013!  :-(

Well, after doing a bit more digging, I came across this article: http://blog.nuget.org/20150226/nuget-3.0-beta2.html

Based on the directions outlined in the article, I needed to use the old Url for NuGet.org (https://www.nuget.org/api/v2/) to replace the NuGet v. 3.x Url.

Well, I decided to try this as a last ditch effort and sure enough it worked like a charm!!

Woo hoo!!

UPDATE: This article also documents a flaw with the NuGet 3.0 release which requires the Nuget.config file to be checked out from TFS: http://docs.nuget.org/release-notes/nuget-3.0.0

You can download the latest release of NuGet Package Manager for Visual Studio 2015 which should fix this issue from here: https://visualstudiogallery.msdn.microsoft.com/5d345edc-2e2d-4a9c-b73b-d53956dc458d

Monday, July 20, 2015

Sitefinity v. 8.1 finally supports ASP.NET MVC 5 and .NET 4.5!

As many current Sitefinity developers have known for many years, Sitefinity has been stuck on .NET v. 4.0 for many, many years and it only very recently added support ASP.NET MVC 4.

Therefore, with the release of Sitefinity v. 8.1, I was pleasantly surprised to see that the Telerik Sitefinity team has finally upgraded and modernized the platform to both support ASP.NET MVC 5 as well as .NET v. 4.5!

You can read the release notes for Sitefinity v. 8.1 here: http://www.telerik.com/account/versionnotes.aspx?id=4223


Visual Studio 2015 Released!

You can read more about the improvements in Visual Studio 2015 here: http://weblogs.asp.net/scottgu/released-today-visual-studio-2015-asp-net-4-6-asp-net-5-ef-7-previews

http://blogs.msdn.com/b/visualstudio/archive/2015/07/20/visual-studio-2015-and-visual-studio-2013-update-5-released.aspx

If you are installing Visual Studio 2015 on Windows 8.1 or Windows Server 2012 R2, you will need to download the appropriate updates in order to successfully install Visual Studio 2015: https://support.microsoft.com/en-us/kb/2919355

For more about the Visual Studio 2015 System Requirements, you can take a look at this article:  https://www.visualstudio.com/visual-studio-2015-system-requirements-vs

You can download Visual Studio 2015 from MSDN Subscriber downloads now.

You can also find some additional relevant Visual Studio 2015 downloads here: https://www.visualstudio.com/downloads/download-visual-studio-vs

Unfortunately, there seems to be some problem with some MSDN Subscriber downloads not being able to display Product Keys for the various Visual Studio 2015 Product SKUs.


As with Visual Studio 2013, you can still log into Visual Studio 2015 with your Windows Live ID associated with your MSDN account to activate your Visual Studio 2015 license.

Saturday, July 18, 2015

The DataAdapter.SelectCommand property needs to be initialized

I recently had to work with ADO.NET once again after working with Entity Framework exclusively for the last several years.

Therefore, unsurprisingly, I had to go back and recall all of the ADO.NET code samples/examples that I learned many, many years ago.

Well, I was attempting to copy some data from a DataTable to a Microsoft Access database table, when I suddenly encountered the following error message:

"The DataAdapter.SelectCommand property needs to be initialized"

Unfortunately, this error message is not very useful in troubleshooting the root cause of the problem.  In fact, I discovered that it was not even close to the actual problem in the code base!

As it turns out, I was using an OleDbCommandBuilder in my code, and this object needed to be passed the DataAdapter class instance as part of the constructor.  Once I did that, my code worked perfectly!

This was my resultant code:
 
public void CopyToAccessDB(DataTable table)
  {
      using (OleDbConnection conn = new OleDbConnection(_connectionString))
      {
          //Open the database connection
          conn.Open();
 
          string strSQL = string.Format("SELECT * FROM {0};", table.TableName);
          OleDbDataAdapter dataAdapter = new OleDbDataAdapter(strSQL, conn);
 
          OleDbCommandBuilder cmdBuilder = new OleDbCommandBuilder(dataAdapter);
          dataAdapter.InsertCommand = cmdBuilder.GetInsertCommand();
 
          //Just to make sure, set the RowState to added to make sure an Insert is performed
          foreach (DataRow row in table.Rows)
          {
              row.SetAdded();
          }//foreach
          
          dataAdapter.Update(table);
      }//using
  }



Friday, July 17, 2015

Using TagBuilders in ASP.NET MVC

If you are relatively unfamiliar with developing in ASP.NET MVC, you may be developing code the "hard way" by using a StringBuilder to generate HTML strings and outputting them into your MVC Razor Views.

Well, fortunately, there is a much easier way to accomplish this through using HTML TagBuilders!  Using the TagBuilder is outlined in this article: http://www.asp.net/mvc/overview/older-versions-1/views/using-the-tagbuilder-class-to-build-html-helpers-cs

Therefore, if you want to output a custom Label Control to your ASP.NET MVC Razor View, you might use code like the following:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
 
namespace ASPNETMVC.HtmlHelpers
{
    public static class HtmlTagHelpers
    {
        public static MvcHtmlString RenderLabelTag(this HtmlHelper helper)
        {
            var labelTagBuilder = new TagBuilder("label");
            labelTagBuilder.AddCssClass("control-label");
            labelTagBuilder.Attributes.Add("title", "someTitle");
 
            var spanTagBuilder = new TagBuilder("span");
            spanTagBuilder.Attributes.Add("style", "color:red");
            spanTagBuilder.SetInnerText("My TagBuilder Label control");
 
            labelTagBuilder.InnerHtml = spanTagBuilder.ToString();
            return MvcHtmlString.Create(labelTagBuilder.ToString());
        }
    }
}


Then in  your Razor View, you simply use code like the following:



@model IEnumerable<System.Security.Claims.Claim>
@using ASPNETMVC.HtmlHelpers
@{
    ViewBag.Title = "Home Page";
}
 
<div class="jumbotron">
    <h1>ASP.NET</h1>
    <p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
    <p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more &raquo;</a></p>
</div>
 
<div class="row">
    <div class="col-md-4">
        <h2>Getting started</h2>
        <p>
            ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
            enables a clean separation of concerns and gives you full control over markup
            for enjoyable, agile development.
        </p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more &raquo;</a></p>
    </div>
    <div class="col-md-4">
        @Html.RenderLabelTag()
    </div>
    <div class="col-md-4">
        @foreach (var item in @Model)
            {
                <p>@item.Value</p>
            }
    </div>
</div>

That is all there is to it!!

Thursday, July 16, 2015

Preventing Cross-site Request Forgery attacks in ASP.NET MVC

If you were using releases of ASP.NET MVC older than MVC 4, you may not know about the additional measure to prevent Cross-site Request Forgery attacks that was introduced with ASP.NET MVC 4.

Fortunately, implementing this functionality in your MVC 4 and MVC 5 Web Applications is relatively simple to accomplish!

In your ASP.NET MVC Razor Views, you simply add the following HTML Helper to the top of the Razor Form:

@Html.AntiForgeryToken()



Then in your MVC Controller for the [HttpPost] action method, you add the following attribute:




[ValidateAntiForgeryToken]

Your resulting [HttpPost] method should therefore look something like this:

 



[HttpPost]
[ValidateAntiForgeryToken]

That is all that is required to prevent Cross-site Request Forgery attacks in ASP.NET MVC!!

64-bit Microsoft Access Engine

There are numerous applications throughout the world that still use the Microsoft Access database.  The problem with using the Microsoft Access database is that traditionally Microsoft Access has always been a 32-bit assembly reference.

Well, fortunately, Microsoft released a 64-bit version of the Microsoft Access Engine which you can download from here: https://www.microsoft.com/en-us/download/details.aspx?id=10910

There is also a Service Pack release for the Microsoft Access Engine: http://www.microsoft.com/en-us/download/details.aspx?id=26605

Get Visual Studio to use the 64-bit version of IIS Express

By default, when you use Visual Studio, the version of IIS Express that Visual Studio uses will always be the 32-bit version.

Fortunately, though, you can get Visual Studio to use the 64-bit version of IIS Express instead!!

To do so, you have to go into Tools-->Options-->Projects and Solutions-->Web Projects

Then, you simply check the checkbox for "Use the 64-bit version of IIS Express for web sites and projects"


Tuesday, July 14, 2015

Clear your Team Foundation Server credentials

If you have ever logged into TFS using Visual Studio and then checked the checkbox for "Remember my credentials", you may encounter problems with logging into TFS in the future (especially if you change your Active Directory domain password):






Therefore, you may need to clear out your TFS credentials at some point in time!

Fortunately, that is easy enough to accomplish!

You simply have to go into the Control Panel and click on User Accounts-->Manage your credentials


You will then have to click on "Windows Credentials"





There, you should be able to see your stored Windows Credentials:





You can then simply click on the Remove button to clear out your previous credentials.  Then, all you have to do is shut down Visual Studio and re-launch it.  The next time you launch Visual Studio and attempt to connect to TFS, you should be once more prompted for your TFS credentials!

An outdated version of this solution was originally documented several years ago on this MSDN Blog: http://blogs.msdn.com/b/visualstudioalm/archive/2012/08/29/clearing-the-credentials-for-connecting-to-a-team-foundation-server.aspx






Saturday, July 11, 2015

Affordable ASP.NET Hosting Providers that support SQL Server 2012/Windows Server 2012

There are numerous ASP.NET Hosting providers out there and it is very difficult to sift through and find hosting providers which support all the latest and greatest technologies as well as provide common features that developers always need.

Some ASP.NET Hosting providers such as Discount ASP.net, always provide the latest and greatest platforms, but they do not bundle SQL Server pricing along with their hosting costs.

Here are some of the ASP.NET Hosting providers that I have found/discovered which are quite affordable and also bundle SQL Server hosting with their hosting costs.

When I created this list, I was particularly looking for vendors which kept up with the latest technology platforms such as SQL Server 2012 and Windows Server 2012.  There are plenty of other vendors which may still be offering SQL Server 2008 R2 on Windows Server 2008/2008 R2 hosting, but I wanted IIS 8 support with SQL Server 2012.

So without further ado, here is the list:


  1. http://www.winhost.com/windows-hosting-plans.aspx
  2. http://www.webhostforasp.net/asp.net-web-hosting/plans.aspx
  3. http://www.asphostcentral.com/Windows-Shared-Hosting-Plans.aspx
  4. http://www.smarterasp.net/hosting_plans
  5. http://www.mywindowshosting.com/hosting_plans 
  6. https://host4asp.net/ 
  7. http://www.arvixe.com/asp_net_web_hosting
  8. http://www.seekdotnet.com/asp.net-web-hosting/personalplan.aspx
  9. http://www.hostbuddy.com/ 
  10. http://asphostportal.com/Windows-Shared-Hosting-Plans 
  11. http://www.myasp.net/hosting_plans 
  12. http://www.1and1.com/ 

Friday, July 10, 2015

ASP.NET Software Licensing Solutions

I recently had to evaluate an affordable software licensing solution for an ASP.NET MVC Web Application that supported the following 2 requirements:

  1. Support for module-based licensing
  2. Support for concurrent user licensing/floating licenses
  3. Support for customer and product data management

 I evaluated the following software licensing solutions:

  1. ElecKey: http://www.sciensoft.com/products/eleckey/
  2. DeployLX: http://xheo.com/products/copy-protection
  3. SoftwareShield: http://www.softwareshield.com/
  4. CryptoLicensing: http://www.ssware.com/cryptolicensing/cryptolicensing_net.htm
  5. Manco .NET Licensing System: http://www.mancosoftware.com/licensing/Index.htm  
  6. Infralution Licensing System: http://www.infralution.com/licensing.html
  7. IntelliLock: http://www.eziriz.com/intellilock.htm

ElecKey

After downloading and installing ElecKey, I was surprised to know that they, by far, had the most extensive set of code samples amongst all of the above vendors for supporting various different scenarios for licensing ASP.NET Web Applications including concurrent user licensing.

However, the code samples were extremely complex and convoluted and concurrent user licensing setup required setting up a separate network licensing server.  The support was not very responsive and the time it took to set up and get a particular code sample running was quite extensive.  In addition, all of the code samples were built using Visual Studio 2008 and the help documentation was very outdated referring to using Visual Studio 2005 or Visual Studio 2008 as the development tools/development IDE.  Trying to understand all of the code in order to integrate it into my own solution was simply too difficult for me to continue working with the platform.

DeployLX

DeployLX did not ship ANY code samples with their product and instead relied on providing their code samples from their website.  The code samples that were provided on the website were very minimal and the support staff was not helpful at all in providing additional code samples or examples, thus making the decision to NOT choose DeployLX as a software licensing solution very easy.  In addition, there was no Customer or Product Management capabilities within the software reinforcing the decision to not choose this as a viable software licensing solution.



SoftwareShield

SoftwareShield was yet another software licensing solution which did not ship ANY code samples with their product.  Even worse, there were absolutely NO code samples/examples listed on their website.  Not choosing this product was a complete NO-BRAINER.

CryptoLicensing

CryptoLicensing provided a lot of functionality for managing licensing including the generation of license keys and serial codes/serial numbers.  It also supported storing license information in a SQL Server database as well as provided a list of custom features that you could select when creating/generating your license codes.  Like ElecKey, their code samples were very outdated--dating back to Visual Studio 2008 projects, however, their set of code samples were much smaller than the samples provided by ElecKey.  The biggest feature it was missing, however, was that the product was very license-oriented and provided very little functionality in terms of being able to manage customer and product data.  CryptoLicensing provided the ability to create custom User Data Fields, but there was no centralized management around managing all of this User Data as Customer Data.  This was a big reason for not choosing this product as a viable software licensing solution since customer and product data management was an ABSOLUTE MUST.



Manco .NET Licensing System

Shortly after installing Manco .NET Licensing system, I attempted to launch the License Manager.  I immediately got a SQL Server exception when attempting to launch the executable.  Browsing through the various tabs in License Manager gave me no insight as to how to use the product, so I immediately gave up on investigating it any further.  There were numerous code samples provided on the Manco .NET website for various different licensing scenarios, but if the product is not intuitive and easy-to-use from the very beginning, it will be difficult to support within nearly any organization especially for non-technical support and sales staff who will be generating the license keys for the products and the customers.



Infralution Licensing System

Infralution, without a doubt, had the best and most polished User Interface out of all the products in this list.  Unfortunately, much like the Manco .NET Licensing system, figuring out how to get started with using the tool was very non-intuitive.  Even after reviewing the Help documentation, I was not able to figure out how to set up my customers and products and associate them with generated license keys.   In addition, the code samples provided with the product were very bare-bones and minimalistic thereby providing very little help in getting up and running with the product.  As with the Manco .NET Licensing system, I finally gave up on investigating the product any further.

IntelliLock

Out of all the software licensing solutions evaluated, IntelliLock by far had the most helpful and responsive support staff.  Numerous code samples were shipped with the product for various different versions of Visual Studio and even though there were no code samples for module-based licensing or concurrent user licensing for an ASP.NET Web Application, the support staff was kind enough to provide code samples/examples on how to complete these tasks.  Overall, the code was easy enough to understand that it was a relatively simple task to incorporate the licensing solution into my own ASP.NET Web Application.

The excellent support and ease-of-use earned big bonus points for IntelliLock amongst all the vendors to make this software licensing product my solution of choice!!






Thursday, July 9, 2015

Wednesday, July 8, 2015

Sorry, we're having trouble reaching the server

I recently set up a SharePoint Server and every time I attempted to use the People Picker, I got the dreaded message "Sorry, we're having trouble reaching the server."



I looked at a wide variety of articles concerning this issue and our particular issue had nothing to do with memory allocated to the server, so I began investigating other solutions.

Since we were using Disjoint Namespaces in our Active Directory domain, I figured there might be a problem with the People Picker due to this.

Fortunately, I came across this SharePoint article:  https://technet.microsoft.com/en-us/library/gg602075.aspx

Now, I LOVE PowerShell, so I was not about to resort to the command line to execute these commands, so I created my own version of the PowerShell commands:

$STSADMPath = @"
"C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\BIN\STSADM.EXE"
"@
$SPPassword = "P@ssw0rd"
 
$STSSetPasswordCmd = "cmd /c $STSADMPath -o setapppassword -password $SPPassword"
Write-Host $STSSetPasswordCmd
Invoke-Expression -Command $STSSetPasswordCmd


$STSADMPath = @"
"C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\BIN\STSADM.EXE"
"@
$SharePointUrl = "https://sharepointdev.mycompany.com"
$DomainName = "dev.mycompany.com"
$LoginName = "mycompanydev\shareptadmin"
$LoginPwd = "P@ssw0rd"
 
$STSSetPeoplePickerCmd = @"
cmd /c $STSADMPath -o setproperty -url $SharePointUrl -pn peoplepicker-searchadforests -pv "domain:$DomainName,$LoginName,$LoginPwd"
"@
Clear-Host
Write-Host $STSSetPeoplePickerCmd
Invoke-Expression -Command $STSSetPeoplePickerCmd

Once I ran the STSADM People Picker command, my People Picker issue was resolved!!


SharePoint Web Services Application Pool stopped by default

When you initially set up your SharePoint Server, you might not notice that even though the SharePoint Web Services web site is running, the SharePoint Web Service Application Pool is actually in a stopped state!!






As you can probably guess, this leads to an incorrect conclusion thinking that the SharePoint Web Services website is actually running when it is factually stopped due to the Application Pool.

As you can probably guess, starting the "SharePoint Web Services Root" Application Pool will get your SharePoint Web Services website up and running properly.


Visual Studio 2015 will be released on July 20th, 2015!!

If you haven't already heard the exciting news, S. Somasegar has posted that Visual Studio 2015 will be released on July 20th of this month!!

You can read his posting here: http://blogs.msdn.com/b/somasegar/archive/2015/06/29/save-the-date-visual-studio-2015-rtm-on-july-20th.aspx

Tuesday, July 7, 2015

Connecting to a Windows Azure website via FTP

If you want to connect to a Windows Azure website via FTP, you have to first log into the Windows Azure portal and go into the Dashboard for your Azure website:






Once you have done that, you can either click on the link to "Reset your deployment credentials" or if you have not already set them up, then you may see a link to "Set your deployment credentials"

Once you have clicked on that link, you will get a prompt similar to the following:




Once you have specified your deployment credentials, you will then see the relevant FTP user and site information needed to connect to your Windows Azure website!




Friday, July 3, 2015

Cannot reset the secure channel password for the computer account in the domain.

I recently joined a computer on my network to a domain and after performing a reboot, I got the following error message:

"The trust relationship between this workstation and the primary domain failed."


Having encountered this problem before, I decided to try the fix outlined in this article: http://blog.blksthl.com/2013/03/18/fix-the-trust-relationship-between-this-workstation-and-the-primary-domain-failed/

Unfortunately, when I ran the command, I got the following error message:

"Cannot reset the secure channel password for the computer account in the domain."

I tried numerous other articles to resolve the issue, including this Microsoft support article: https://support.microsoft.com/en-us/kb/175024

Unfortunately, all of these attempts were in vain.

Finally, I was forced to remove the computer from the domain and rejoin the domain.  After re-booting the machine, I was able to log back into the domain!!


Thursday, July 2, 2015

Regenerate Designer files for ASP.NET Web Applications

If you have recently worked with Visual Studio 2013 or Visual Studio 2015, you may have noticed that they have removed the "Convert to Web Application" feature that was previously available in earlier versions of Visual Studio.

This feature essentially allowed files that were copied or imported from an ASP.NET Web Site to be converted into an ASP.NET Web Application by regenerating the necessary .designer files needed in ASP.NET Web Application projects.

Therefore, with these recent releases of the IDE, the process of converting ASP.NET Web Site has largely been a manual process.

Fortunately, there is a command-line tool that can now help you regenerate those ASP.NET designer files for you!  http://sourceforge.net/projects/redesigner/

If you believe that Microsoft should provide the ability to regenerate ASP.NET designer files directly from within the IDE, then you should vote for this UserVoice item here: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/8676757-provide-the-ability-to-regenerate-asp-net-designer

Escaping string variables in C#

I was recently working on an ASP.NET Web API project where we would be accepting incoming strings from non .NET clients.

Therefore, we did not necessarily know the format of the incoming strings, therefore, we would have to ensure that all of the string input was valid for JSON serialization before performing the serialization.

Therefore, we were looking for a way to escape any incoming strings that were assigned to C# variables.

Well, fortunately, there is a very easy way to accomplish this using the Regex.Escape method!!  https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.escape%28v=vs.110%29.aspx

As you can probably guess, I used this method on my incoming strings and I was able to escape my strings for successful JSON serialization!!

Tools for creating Regular Expressions in C#

From time to time, I have to use Regular Expressions in my C# development and I have to admit that I am by no means a "Regular Expression Expert".

Therefore, like many other developers, I have to rely on 3rd party tools to help me develop my Regular Expressions.

The 3 tools that I use most heavily when developing and testing my Regular Expressions are the following:

  1. Expresso: http://www.ultrapico.com/expresso.htm
  2. RegexMagic: http://www.regexmagic.com/
  3. RegexBuddy: http://www.regexbuddy.com/

Of all the 3 tools, I use Expresso the most heavily since it is an excellent tool for designing Regular Expressions. 







RegexMagic is not nearly as intuitive and easy-to-use as Expresso, but provides the added benefit of providing sample C# code for you to use in your C# application:






Finally, RegexBuddy combines some of the features from Expresso as well as RegexMagic to also provide assistance with generating Regular Expressions to use in your C# application:







Hopefully these tools will help you develop Regular Expressions as part of your C# development as well!!

Wednesday, July 1, 2015

Validating JSON using Newtonsoft Json.NET

If you have a JSON string that you would like to validate, then you will definitely want to take advantage of the Json.NET Schema Validation: http://www.newtonsoft.com/jsonschema

You can download the NuGet package for Json.NET schema from here: https://www.nuget.org/packages/Newtonsoft.Json.Schema/

Telerik Fiddler Proxy Settings

If you use Telerik Fiddler for debugging your ASP.NET web applications, you may notice that it sets up a Proxy Server as part of your Windows Settings as follows:









However, this may introduce problems when you are attempting to browse the Internet WITHOUT Telerik Fiddler running such as getting error messages that the "proxy server refused the connection"! 

Therefore, you have to turn of the Proxy Server under Fiddler-->Tools-->WinINET options, then click on the LAN settings button and change the configuration under "Automatic configuration" to "Automatically detect settings":



You can then close Fiddler and you should be able to browse the Internet normally once again!!