Category Archives: ASP.NET

IIS Express – Disabling anonymous authentication

StackOverflow: IIS Express is automatically disabling anonymous authentication for my project, why?

To disable anonymous authentication, I found updating the following element in the project file (i.e. csproj, vbproj) allowed me to debug my application with anonymous access.


Changing the IISExpressAnonymousAuthentication setting to enabled fixes the issue (it can also be done within Visual Studio, select project, F4, set Anonymous Authentication in the properties grid to Enabled).

String.Format to set a constant in .NET

Today I began working on the base framework for a new project. In the past we would just copy an existing project and remove what we don’t need, so I thought this would be a good time to make the framework more generic to speed up this part of the process for future projects. This also would prevent having to copy and replace for constants, variables, functions, class names, etc. based on the name of the project as we’ve done in the past. I say all of this to point out something I found that was new to me.

There were constants in the framework that needed to be changed, for example:

Private Const cUserName As String = "ProjectUserName"

Where “Project” in “ProjectUserName” would need to be changed based on the name of the project, this happen for several other constants. So I tried setting the constant like this:

Private Const cName As String = String.Format("{0}UserName", AppSetting.ProjectID)

And got “Constant expression is required.” which wasn’t clear to me. After some research I found that a constant has to be set by a compile time constant and the result of String.Format isn’t a compile time constant.

I finally just changed the constant to a shared readonly variable.

Private Shared ReadOnly cUserStoreName As String = String.Format("{0}UserName", AppSetting.ProjectID)

FreeTextBox – Set default font and size

When using the FreeTextBox HTML editor, the default font styles have to be set in the stylesheet specified in the DesignModeCss property.

FreeTextBox - Set default font and size

In my case I created a stylesheet and saved it as /App_Themes/Default/FreeTextBox.css, with the following:


Then I set the DesignModeCss property:

<uc:FreeTextBox ID="ucFreeTextBox" DesignModeCss = "~/App_Themes/Default/FreeTextBox.css" Runat="server" />

And that’s it.

SQL Server Reporting Services (SSRS) – Download Multiple RDL files

ssrs dashboardI needed to migrate multiple SSRS reports (.rdl’s) between environments (production -> qa ->development) and didn’t want to download/upload each individual report. I searched but couldn’t find a solution built into SSRS report manager, so I began my Google search. I found a solution on Code Project (SSRS Downloading .RDL Files) that worked after some tweaking.

This project written in C# using Visual Studio 2010, and all I really needed to change was the URL to the SSRS web service to get the project up and running. Some of the other changes I made included building the folder structure as it is on the SSRS server and only saving the .rdl files.

Here’s what I came up so far:

After I ran the project and downloaded all the reports really fast, I still had to manually upload the ones I needed to migrate. When I have time hopefully I can implement uploading to an SSRS server into the project.

Collection Types Commonly Used in .NET

This is a question that was asked during an interview and I didn’t know the correct answer, so I thought I would add the information I found to “My Online Notepad“. Maybe it can also help someone else.

  • Hash Tables – A collection of key/value pairs that are organized based on the hash code of the key. The Dictionary(Of TKey, TValue) and ConcurrentDictionary(Of TKey, TValue) classes have similar functionality as the Hashtable. The elements of Hashtable are of type Object, so boxing and unboxing typically occur when you store or retrieve a value type.
  • Queues – A first-in, first-out collection of objects. This is useful if you want to access the information in the same order that it is stored in the collection. There are three primary operation that can be performed on Queues and its element: Enqueue, Dequeue, Peek
  • Stacks – A simple last-in-first-out (LIFO) non-generic collection of objects. There are three primary operation that can be performed on Stacks and its element: Push, Pop, Peek
  • Dictionaries – A collection of keys and values. Typically provides better performance than a Hashtable for value types.
  • Lists – A strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and manipulate lists.

FreeTextBox – FontFacesMenuList , FontFacesMenuNames, FontSizesMenuList, FontSizesMenuNames

I was able to change the font-family and font size drop down lists, see example below using VB.NET.

<FTB:FreeTextBox runat="server" ID="ftb" />
Dim fontFaces() As String = {"Time New Roman", "Georgia", "Arial", "Tahoma", "Wingdings"}
Dim fontFaceNames() As String = {"Time", "Georgia", "Arial", "Tahoma", "Wingdings"}
ftb.FontFacesMenuList = fontFaces
ftb.FontFacesMenuNames = fontFaceNames

Note: The list of font sizes available are 1-7, the default is 3.

Dim fontSizes() As String = {"1", "2", "3", "4", "5", "6", "7"} 
Dim fontSizeNames() As String = {"8", "10", "12", "14", "16", "18", "20"}
ftb.FontSizesMenuList = fontSizes
ftb.FontSizesMenuNames = fontSizeNames


“HTTP Error 404 – File or Directory not found” error message when you request dynamic content with IIS 6.0

I ran across this problem with an ASP page and found a solution on the Microsoft Support site.

Active Server Pages (ASP) page, ASP.NET page, Internet Services API (ISAPI) application, or Common Gateway Interface (CGI) application on a Windows Server 2003 server running Internet Information Services (IIS) 6.0, give the following error messages:

  1. HTTP Error 404 – File Not Found
  2. HTTP Error 404 – File or Directory not found

IIS 6.0 was set to serve only static HTML pages by default on Windows Server 2003

Using the IIS manager Allow Active Server Pages under the Web service extensions node.