.NET, Archive, ASP.NET, aspNETserve, C#

aspNETserve 1.3: What’s New

Jason / August 19, 2008

As I mentioned in my last post, aspNETserve 1.3 has just been released. And with it comes some exciting changes. Here is an outline of some of the most notable changes:

HTTP Persistent Connections

aspNETserve’s goal is to target version 1.1 of the HTTP protocol, and prior to version 1.3 of aspNETserve it had an obvious shortcoming in that goal. It did not even attempt to keep “Keep-Alive” (aka, persistent) connections around. The server naively closed the connection after each request.

The new aspNETserve.Server object in version 1.3 has full support for persistent connections, and with it introduces a couple of new properties:


This property represents the maximum number of simultaneous connections allowed. Once the maximum amount has been reached additional requests will be declined.


A period of time (in milliseconds) that aspNETserve will wait for subsequent communications on a previously established connection.

Windows Service Server

A Windows service called aspNETserve.Ice (pun intended) allows aspNETserve to process requests in the background. Additionally, this allows request processing without a user having to first login and launch the SimpleServer UI.

aspNETserve.Ice reads it configuration from an XML file whose schema is define on the wiki page ConfigSchemaOverview.

Here is a simple example of what the XML file looks like:

<?xml version="1.0" encoding="utf-8"?>
<server xmlns="http://aspnetserve.googlecode.com/svn/tags/Release%201.3/aspNETserve/Configuration/Xml/aspNETserve.config.xsd">
        <application physicalPath="c:\temp">
                <domain name="www.example.com" virtualPath="/" />
                <endpoint ip="" port="80" />
                <endpoint ip="" port="443" secure="true" />
read more

.NET, Archive, ASP.NET, aspNETserve, C#

aspNETserve Update

It has been a while since I have mentioned anything about aspNETserve, so I figured it was due time for an update. Since the last update in December of 2007 there wasn’t any activity until recently. Between being distracted with a plethora of personal and professional obligations the project took a back seat. read more

.NET, Archive, ASP.NET

Handling Unknown Controller Actions In ASP.NET MVC

In my last article I discussed how to use a wild card route to capture completely malformed URLs. But what if a URL matches to a controller in which the requested action cannot be found?

For example, when a visitor requests http://example.com/product/listing when there is no listing action on the product controller. In this example your visitor would be greeted by the a less than friendly page stating:

Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. read more

.NET, Archive, ASP.NET


Jason / February 23, 2008

Manning has now announced the early access available of the book ASP.NET MVC In Action through their MEAP program.

The title is scheduled to be published in October of 2008, but through the early access program you can start reading the chapters as the authors write them. This particular book looks promising as it will provided a pragmatic explanation of MVC tailored towards ASP.NET developers. read more

.NET, Archive, Software Design

The Wonders Of InternalsVisibleTo

Jason / November 8, 2007

I do not know how I missed this, but just today I found out that you can expose an assembly’s internal methods/properties/classes to a "friend" assembly. Normally internals are only accessible to members of the same assembly, and are often used to hide "plumbing" methods and utilities classes.

For many reasons you often want to separate your code into multiple assemblies, perhaps one for each application layer or some other logical boundary. A problem arises when two or more assemblies need access to each others internals. Prior to .NET 2.0 you had two choices, either expose these plumbing methods as public, or lump as much of your code into one assembly as was needed to keep the plumbing internal.

In comes .NET 2.0’s InternalsVisibleTo attribute. This attribute is applied on the assembly level, and allows the assembly to give internal access to specific assemblies.

For example:

Say you have two assemblies, MyExample.DomainObjects & MyExample.ServiceLayer. In the DomainObjects assembly you have the following abstract class:

namespace MyExample.DomainObjects{
public abstract class DomainObject{
//.... other things....
public virtual DateTime LastModifiedDate{
get { ... }
internal set { ... }
read more

.NET, Archive, C#, Software Design

Parsing RSS From C#

I set out to write a RSS parser in C#. I know that several existing libraries are available for .NET that parse RSS streams, but out of curiosity I wanted to give it a go anyway.
Before I get started, for those interested in RSS libraries for .NET checkout RSS.NET or RSSConnect, to just name two.

As .NET developers we have some really powerful tools available to us that are built directly into the .NET framework. Take, for example, Serialization. In .NET we can turn an object into an XML resource using the XmlSerializer class, provided that the class is Serializable. In fact, the XmlSerializer object will even attempt to populate an object from an XML resource.

Visual Studio ships with a tool called XSD which can turn an XML Schema Definition into a C# class. Knowing that RSS is expressed as an XML resource, I set out to find an XSD for RSS. After some searching I found this site, which contains an XSD for RSS that the site’s author wrote. For posterity I have placed a mirror of that file on my own site, which you can find here.

Before continuing on, I need to pause and look ahead. The XSD that I found did not work out of the box, and I had to make a small modification to get it to work. I removed a reference to the RSS schema namespace from the XSD. The modified XSD can be downloaded from here

Now, armed with an XSD, we can have the XSD program make some classes for us. From a command prompt (preferable the “Visual Studio Command Prompt” command prompt) type:

xsd RSS20.xsd /classes

Provided that RSS20.xsd is the name of the RSS XSD, and that you are currently in the same directory as RSS20.xsd, the XSD program should output a single file called RSS20.cs. The C# source file that XSD produced contains a class definition for each RSS entity, most notable the root node called “rss”.

With classes that represent RSS, we can now use the XmlSerializer object to easily populate an object with RSS data. For example:

     string rssXml = "... your rss data here ...";
XmlSerializer helper = new XmlSerializer(typeof(rss));
rss obj = (rss)helper.Deserialize(new StringReader(rssXml));

The above code snippet, will create an rss instance called “obj” from raw RSS data. But, you don’t want to have to do this everytime you want to parse RSS. Instead, it would be helpful if that logic was encapsulated by the rss object. Fortunately, the classes produced by the XSD program are all partial classes. So, in a separate .cs file, we can re-declare the rss class and expand upon its functionality.

//declare another portion of the "rss" object.
public partial class rss{
//add more methods to "rss" here
read more

.NET, Archive, ASP.NET, Javascript, Visual Studio

Visual Studio 2005 and .NET 3.5 Don’t Play Well Together

As many of you have, I also have experimented with the pre-releases of .NET 3.5 and Visual Studio codenamed Orcas. I, for better or worse, installed this pre-release software on my primary development machine which has Visual Studio 2005.

Despite having .NET 3.5 installed on my machine, my primary development occurred in .NET 2.0 via Visual Studio 2005. I had not experienced any problems with this setup until the other day. While attempting to build and publish an ASP.NET 2.0 website with AJAX extensions, I ran into a cryptic server error when executing the site on a staging server. The error was:

Could not load file or assembly 'System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 
or one of its dependencies. The system cannot find the file specified.

The System.Web.Extensions assembly is the ASP.NET AJAX assembly, so at first I simply thought that the staging server did not have AJAX extensions installed. After installing the AJAX extensions, the issue remained unresolved. A quick look in the machine’s GAC showed that it had version 1.0.61025.0, which is the latest version. Inspection of my development machine’s GAC showed both 1.0.61025.0 and installed.

At this point I was puzzled how my machine had an unofficial version of AJAX extensions, and how my website was referencing it. Next I looked at the web.config of my site to see if I could just change the referenced version to 1.0. However, inspection of the web.config reveled:

<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

read more