Hosting an ASP.NET Web Api on an IIS Express Server

Admittedly, It took me some time to figure out how to properly configure an IIS Express Server on a locally hosted machine so that I could establish a connection to the server from a secondary computer. I have although finally gotten the gist of it, so I have put together a guide for others who wish to host their own IIS Express Server.


One of my major issues was that I didn’t run Visual Studio as an Administrator, so keep that in mind should you run into problems.

Additionally, if this guide doesn’t cut it for you, you may also try by directly specifying the name of your computer as described in this guide. When I tried, although, I experienced that I couldn’t properly establish a connection to the server when reserving an URL.

Hosting an ASP.NET Web Api on an IIS Express Server

1. First, we’ll need to create the virtual directoy:

1.1 Open Visual Studio as Administrator

1.2 Open and expand your project

1.3 Navigate to “Properties” -> “Web”

1.4 Ensure that the “Project Url” is “http://localhost:64485”

1.5 Click “Create virtual directory”

2. Now launch the site by:

2.1 Right-clicking on your ASP.NET Web Api project

2.2 From here, select “Set as StartUp Project”

2.3 Launch the site

3. Stop debugging & close Visual Studio

4. Now, in Windows:

4.1 Navigate to”C:\Users\Dave\Documents\IISExpress\config”

4.2 Open the “applicationhost.config” file”

4.3 Search for “bindings”

4.4 Find the entry which contains the name of your API

4.5 Add the highlighted line below the existing localhost binding

4.6 Save

5. Lastly, you’ll need to configure your firewall

5.1 In Windows, open “Control Panel”

5.2 Click “Windows Firewall”

5.3 Click “Advanced Settings”

5.4 Click “Inbound rules”

5.5 Select “Port”

5.6 Click “Next”

5.7 Select “TCP”

5.8 Enter port 64485

5.9 Click “Next” twice

5.10 Provide a name of your choosing

6. Finally, we’ll need to launch the site once more

6.1 Open Visual Studio as Administrator

6.2 Find your project

6.3 Launch the site

You should now be able to access the API using:

1. http://localhost:64485/


// David

Programming, Xamarin.Forms, Xamarin.Forms.Android

Obtaining a Google Maps API Key

I recently observed an issue when debugging my Xamarin.Forms.Android solution which uses Xamarin.FormsMaps in two different development environments.

The problem was, that I received an error stating that I was missing authentication with the Google Maps API in only one development environment.

Solving the issue

This guide assumes that you have already succesfully established a connection with the Google Maps API in at least one development environment. If you havn’t already worked with Xamarin.FormsMaps before, here is a guide on how to get started, and here is a detailed list of the required permissions in your Android project.

Anywho, on to the issue at hand:

  1. First, obtain the SHA1 fingerprint from your debug key by following this guide
    1. While you’re at it, grab the SHA1 fingerprint for your release key as well by following the same process, but by select the certificate you use for release
  2. Open the Google Developers Console
  3. Select your project and navigate to “APIs & auth” => “Credentials”
  4. In here, click “Edit allowed Android applications”
  5. For each key you have (I’ve got 3 in total: 2 development enviroments, and 1 release certifcate) add a new line with the following contents:
    1. <SHA1-fingerprint>;com.your.packagename
  6. Click “Update”

By now, your “Key for Android applications” should resemble that of the screenshot below. If it does, the Google Maps API has been succesfully registered with both your development and release certficates.

Android SHA1 Fingerprints

Android SHA1 Fingerprints

// Dave


Resolving “Compile to dalvik: Unexpected top-level error” under Xamarin.Android

If you are using the following configuration under Xamarin.Android, you may experience an issue (Compile to dalvik: Unexpected top-level error) which prevents your build from succeeding:

  • Xamarin.Forms
  • Xamarin.Forms.Maps
  • Deploying to release

Resolving the issue

To resolve this issue, simply do the following:

  1. Right-click on your Xamarin.Android project
  2. Select “Properties”
  3. Open “Android Options” => “Advanced”
  4. Set “Java Max Heap Size” to 1G

Now, you should be able to build your Xamarin.Android project in release mode once more.

// Dave