Wednesday, August 20, 2008

ASP.NET Windows Authentication (Anonymous, Basic, Digest and Windows Integrated Authentication) – Part 1

Windows Authentication utilizes the authentication capabilities of IIS so that you don't have to write any custom code. Compared to other authentication mechanisms, Windows authentication does not pass the user credentials over the wire. Windows authentication also provides a seamless user experience. After IIS completes its authentication, ASP.NET uses the authenticated identity's token to authorize access.

Windows Authentication is usually implemented when the users are part of Windows domain (Microsoft Windows NT domain controller or within Microsoft Windows Active Directory) and the authenticated users are to be impersonated so that the code is executed in the same security context of the user's Windows account.

There are four different kinds of Windows authentication options available that can be configured in IIS

  • Anonymous
  • Basic authentication
  • Digest authentication
  • Windows Integrated Authentication
  • Client Certificate Mapping

Anonymous Authentication

Anonymous authentication gives users access to the public areas of your Web site without prompting them for a user name or password. With Anonymous authentication, the server does not request the client to send user credentials. It is a good choice when our site or service is publicly available and we do not need to know the identity of the caller.

IIS provides stored credentials to Windows using a special user account, IUSR_machinename or the account configured in IIS for the anonymous user or the IIS system account.

Using Anonymous Authentication offers the best performance because Anonymous authentication imposes no appreciable overhead.

In the next part of the series I will explain Basic and Digest Authentication

Tuesday, August 5, 2008

Creating a .msi file using Windows Installer XML (WiX)

The Windows Installer XML (WiX) platform is a set of tools and specifications that allow you to easily create Windows Installer database files. The WiX tools model the traditional compile and link model used to create executables from source code. For WiX, source code is written in XML files. These files are validated against a schema, wix.xsd and then processed by a preprocessor, compiler, and linker to create the desired result.

The latest version is available as free download from this location.

In this post I will explain how to use WIX to create an installation package file (.msi) for a web application using Visual Studio 2008.

  • Create a new WiX project in Visual Studio IDE by selecting WIX Project from the list and click on new project.
  • Open the Product.wxs file created as part of the project and change the required field values (ProductName, Manufacturer etc)

    <Product Id="YOUR GUID - 944B15CA-A13A-4d39-94AC-6599633A7C84" Name="YourWebsite" Language="1033" Version="" Manufacturer="Your Name" UpgradeCode=" YOUR GUID - 40B2FF80-88DD-48fc-A081-1F6AD4E52BA0">

  • In the Product.wxs file replace the section where you find the comment

    With the names of the components you need to deploy into your folder.
    Directory Id="InstallDir" Name="Your Folder Name">
    <Component Id="DefaultPage" Guid="6CEFE537-A4BE-4c67-8C20-86F6E0CC8240">
    <File Id="MyDefaultPage" Source="..\Default.aspx" DiskId="1">File>

  • Add Xml schema definition for IISExtensions to the Product.wxs file

    <Wix xmlns="" xmlns:iis="">

  • To generate the GUID for each component use the Tools->Create Guid option from Visual Studio.

  • Copy the generated GUID and paste that to the relevant section.

  • If you need to move your assemblies into the Bin folder you need to create another directory structure under the main folder.

    <Component Id="DefaultPage" Guid="6CEFE537-A4BE-4c67-8C20-86F6E0CC8240">

    <File Id="MyDefaultPage" Source="..\Default.aspx" DiskId="1">File>


    <Directory Id="YourProjectBin" Name="Bin">

  • Add sections for assemblies to be deployed in the Bin directory

    <Directory Id="YourProjectBin" Name="Bin">

    <Component Id="YourProjectAssembly" Guid="PAF675GF-9087-4661-88GH-5GH48388HJK2">

    <File Id=" YourProjectAssemblyDll" Source="..\Bin\SellKeys. YourProjectAssembly.dll" DiskId="1">File>


  • If you need to deploy the assemblies into GAC you need to configure additional parameters like KeyPath and Assembly.

  • Create a section to describe the virtual directory structure for the application.

    <Component Id='YourProjectVirtualDirComponent' Guid='C2F09A52-3DF0-41b9-8B2E-BC8B092AF2AB'>

    <iis:WebVirtualDir Id='YourProjectVirtualDir' Alias='Your Virtual Dricetory Name' Directory='InstallDir' WebSite='DefaultWebSite'>

    <iis:WebApplication Id='YourWebApplication' Name='Your Application Name' />



    Add section for the path of Virtual directory.

    <iis:WebSite Id='DefaultWebSite' Description='Default Web Site'>

    <iis:WebAddress Id='AllUnassigned' Port='80' />


  • Make changes to the Feature section to add ComponentRef to all the components in the previous sections.

    <Feature Id="ProductFeature" Title="Your Application" Level="1">

    <ComponentRef Id=" DefaultPage" />

    <ComponentRef Id=" YourProjectAssembly" />


  • Add a reference to the WIXIIsExtension to the project.

  • Build the project to generate the .msi file.