Rename cookie

You can adjust it in your web.config file, the default is ASPXAUTH:

   <authentication mode="Forms">
      <forms name=".CRM-Cookie" loginUrl="LoginPage.aspx" />

This is useful when running multiple applications from the same server under the same domain. 

What is dependency injection 

A simple definition is:

Dependency Injection is where components are given their dependencies through their constructors, methods, or directly into fields.

For example a class constructor creates an instance of an object. This class is now dependant on that object. If however this object is passed into the constructor this dependancy is decoupled.

For dependancy injection to work correctly each class requires an interface. This will ensure if the object is switched it will still present the same methods, it doesn’t however need to know what these methods do.

Unit testing as one of the main uses for dependancy injection. It allows objects which perform complex data processing tasks to be replaced with an object which provides mock data for testing. The class being tested doesn’t care how this data is created as long as it’s presented in the same format.

Another example is an object provided SQL database access methods. Using dependancy injection we can switch this to another object with MySQL access methods. As long as both objects expose the same methods the objects using them won’t care which one it is.

IIS Express Configuration File

The configuration file is called applicationhost.config It’s stored here:

My Documents > IIS Express > config

usually (not always) one of these paths will work

%userprofile%\my documents\iisexpress\config\applicationhost.config

Update for VS2015

If you’re using visual studio 2015 look here:
$(solutionDir)\.vs\config\applicationhost.config MVC $.ajax performing full post back on button click

One of the biggest mistakes when attaching an html button to an ajax request is not declaring the button type. By default html buttons will submit the entire form, which is not what we want with an ajax request. To prevent this happening make sure button has a type of button e.g.

The following will result in a full post back after executing the AjaxCall JavaScript function.

<button onlick=”AjaxCall()”>Click me</button>

However this will run the AjaxCall JavaScript function but not perform a full post back.

<button type=”button” onlick=”AjaxCall()”>Click me</button>

Debugging MVC web applications

There are two very useful helpers which accompany MVC.


Adding @ServerInfo.GetHtml to your cshtml file will output detailed information about IIS and configuration and variables.


Passing an object to the ObjectInfo help will display the types and variables of the objects properties. In its simplest form use @ObjectInfo.Print(object)

Determining the Exchange Web Services (EWS) URL for authentication

I’ve recently had to write an application which provides Exchange integration for booking meeting rooms. Microsoft provide the Exchange Web Services Management API for use with Exchange 2007 and above. This provides a nice API to performing the usual Exchange functions such as managing inbox’s and calendars.

Before the API can talk to Exchange it requires a connection URL. Microsoft recommend using the Exchange’s Auto Discovery function, however if you want to specify this manually the below will help you find the correct URL.

The Exchange admin can use a PowerShell command on the exchange server

a. Open PowerShell on the Exchange server
b. Type Get-WebServicesVirtualDirectory |Select name, *url* | fl
c. The URL will be provided

Use the Outlook 2007 or 2010 Auto Discovery feature

a. Hold the Ctrl key and right click on the Outlook Icon in the system tray (Note this must be outlook version 2007 or 2010)
b. Select “Test E-mail Auto Configuration” from the menu
c. Type in an email address located on the desired Exchange server
d. Ensure that only the “Use Auto Discover” checkbox is enabled
e. Click “Test”
f. Search the results for the line starting with “Availability Service URL” this line contains the EWS URL Caching

Using the page directive it's possible to control caching on aspx pages. Simply add the following to the top of the page where 600 is the number of seconds to cache for. There are a number of other parameters which can be added but this is the basics for simple caching.

<%@ OutputCache Duration="600" VaryByParam="None" %>