HttpHandler using Default Namespace
March 22, 2009 11:01 AM   Subscribe

Why can't I use the default namespace (i.e., no namespace) with an HttpHandler?

I have an HttpHandler called Handler that I compile into a DLL and put in the /bin folder of my ASP.NET app. Then I have a .ashx file:
<% @ webhandler language="C#" class="Handler" %>
but I get a cannot create type 'Handler' error.
However, if I wrap Handler in a gratuitous namespace, say foo, and change the .ashx to
<% @ webhandler language="C#" class="foo.Handler" %>
it works fine. Why can't I use no namespace, er, the default namespace? Microsoft omits a namespace in many examples of HttpHandlers on the msdn website.
posted by iconjack to Computers & Internet (1 answer total)
 
My understanding was that using a namespace, particularly for a potentially common label like "Handler", is good programming practice. If you had named the handler something like IconjackUniqueHandler then the potential for conflict with an existing function would be less.

Unless there's a compelling reason not to, I'd just use a namespace.

Microsoft omits a namespace in many examples of HttpHandlers on the msdn website.

In my experience, example code in vendor documentation is not necessarily exemplary code.
posted by Deathalicious at 11:31 AM on March 22, 2009


« Older .forward foribidden?   |   Replacing a driveway? Newer »
This thread is closed to new comments.