ASP.NET Core and .NET Core Overview

ASP.NET Core and .NET Core Overview

Microsoft’s big shift







The future of .NET



.NET Core



Any developer, any app, any platform

.NET Overview | Build 2016








ASP.NET/Core Overview | Build 2016


Now, go code…


Visual Studio 2013 high CPU usage




Visual Studio 2013 Browser Link

WCF return JSON, AJAX-enabled WCF Service in less than 3 minutes

I was about to set up some WCF services to handle POST requests to SolrNet and was digging around for solution. Goal was to post a string query to the web service and get JSON objects returned. This can be obtained pretty easily with an AJAX-enabled WCF Service and a bit of jQuery.

Actually you can have this example going in less than 3 minutes!

To serialize my objects to JSON I’m using a ToJson extension method written by Scott Gu. This makes it very easy to just use .ToJson() on your objects or collections, just like using ToString().

Steps to build the web service

1. Create a new WCF Service Application and delete the files IService1.cs and Service1.svc
2. Right click your solution and Add New Item. Search for “Ajax enabled” and choose AJAX-enabled WCF Service.
3. Create a folder called “Helpers” in which you create a static class called “JsonHelper” with the following methods:
public static class JsonHelper
public static string ToJson(this object obj)
var serializer = new JavaScriptSerializer();
return serializer.Serialize(obj);

public static string ToJson(this object obj, int recursionDepth)
var serializer = new JavaScriptSerializer();
serializer.RecursionLimit = recursionDepth;
return serializer.Serialize(obj);

The method takes your object, serializes it to JSON and returns it.

4. Open up your newly created AJAX-enabled WCF Service – Service1.svc and delete the method OperationContract method DoWork().
5. Create a new OperationContract method called HelloWorld() which will look like this:
public string HelloWorld(string personName)
return (new HelloWorldWrapper
Response = string.Format("Hello, {0}", personName),
Error = "",
TimeExecuted = DateTime.Now.ToString(CultureInfo.InvariantCulture)

6. Create a wrapper class for your Hello World method, which we will create a new object of, serialize to JSON and return.
public class HelloWorldWrapper
public string Response;
public string TimeExecuted;
public string Error;

Test test test!

Now you are actually done, but lets test the service. For that we’ll need a HTML page where we execute some jQuery and call our web service. Note that this service will be hosted on a IIS, where as your your front-end call can be on what ever server and site you want.

Right click your project and Add New Item. Create a Web Form for the ease of it.
In the head section insert:
<script src=""></script>
var personNameVar = "Paul";
var dataIn = ‘{‘ + ‘"personName":"’ + personNameVar + ‘"}’;
url: "/Service1.svc/HelloWorld",
type: "POST",
data: dataIn,
dataType: "json",
success: function (data) {
var object = JSON.parse(data.d);
if (object.Error == ”) {
//Alert the persons name
error: function (error) {
alert("Error: " + error.Error);

We are making an AJAX-call to our web service, located at “/Service1.svc/HelloWorld”, sending a post request in JSON format, containing the string personName. In our success function we receive our JSON serialized object and get the Reponse string returned in a alert box.

CTRL+SHIFT+B your project, right click HelloWorld.aspx and “View in Browser”.

For the lazy ones i made a Visual Studio 2012 project on .NET 4.5 framework containing the example. Download: Ajax WCF Test

Run URL from ASP.NET/C#

Sometimes it can be handy to run a URL from a ASP.NET page (eg. aspx, ascx or MVC control). It could be simply executing one or more webservices, without wanting a result back.

It’s actually pretty simple!

string url = "";
using (System.Net.WebClient client = new System.Net.WebClient())

Visual Studio 2012, Web Essentials 2012, Net 4.5

The 15th of August Microsoft released Visual Studio 2012 and .NET Framework 4.5 to Web.
Several usefull tools and blog posts followed the hours after.
Download: Visual Studio 2012

Mads Kristensen from Microsoft also released a new version of Web Essentials for Visual Studio 2012. The essenstials extension let you perform common task faster and easier. Pretty essential indeed ;)
Download: Web Essentials 2012

While your at it, remember to grab the newest versions of JetBrains ReSharper for Visual Studio, which makes your life a lot easier as a programmer. Once you tried it, you wonder how you could ever live without. Resharping, code elimination, autocomplete, etc, etc…
Download: ReSharper

Schott Hanselman wrote a blogpost and posted several videos on getting up to speed with .NET 4.5 and Visual Studio 2012: Visual Studio 2012 and .NET Framework 4.5 is RELEASED – Here’s 5 minute videos to get you up to speed quick

Jason Zander, Vice President for the Visual Studio team wrote a “Top 12 of Visual Studio 2012

Visual Studio 2012

Use Enter as Tab in Windows Forms

Recently I made a Windows Form Application with a lot of text boxes for my work.
After hours of use and testing, we found out it would be more efficient if it was possible to tab from box to box hitting ‘enter’ instead of the tabulator key. Even though you by standard can’t assign it in Visual Studio, it’s actually fairly easy to implement.

All you need to make is one event handler and assign your text boxes ‘KeyDown’ action to use the handler.

//Event handler to handle ENTER as TAB in TextBoxes
private void General_KeyDown(object sender, KeyEventArgs e)
if (e.KeyCode == Keys.Enter)

Select your Text Boxes, go to the properties windows and select the lightning icon. Scroll down to “Key”. Under ‘KeyDown’ select your newly created event handler “General_KeyDown’.

Use Enter as Tab in Windows Forms

Group radio buttons in Windows Form

To have multiple groups of radio buttons that should not affect each other, it is necessary to group them as a GroupBox or Panel.

In Visual Studio, open your toolbox, scroll down to “Containers” and choose your box / panel. All radio buttons in this box / panel will now be interconnected.

Group radio buttons

Clear all TextBoxes

This loop function will clear all TextBoxes in your Form, wherever they are placed.
Comes in handy when creating a “Clear fields” button

private void button1_Click(object sender, EventArgs e)

private void RecursiveClearTextBoxes(Control.ControlCollection cc)
foreach (Control ctrl in cc)
TextBox tb = ctrl as TextBox;
if (tb != null)


I suddenly got this error in my ASP.NET Web Forms project in Visual Studio. Even after creating a new Web Form without content, I was thrown this error. The solution was very simple. All you have to do is rebuild your project.

Server Error in ‘/’ Application.

Parser Error


Parser Error Message: Could not load type ‘Listing’.

Source Error:

Line 1: <%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”8-8_Listing.aspx.cs” Inherits=”Listing” %> Line 2:

Source File: /8-8_Listing.aspx Line: 1