HttpHandlers in ASP.NET without regions
I work a lot with httphandlers (.ashx) in ASP.NET – mostly to generate dynamic XML files for Macromedia/Adobe Flash consumption. It works great and the performance is great in httphandlers compared to webforms, but there is one major problem that Microsoft somehow ignored in Visual Studio 2005: Httphandlers does not support collapsing regions.
By regions I mean these
#region Name of region
…
#endregion
You can do regions in httphandlers like everywhere else in Visual Studio, but they will not collapse, so they becomes somewhat pointless. I’ve found this to be a huge problem for the maintainability of httphandlers, because you cannot group the different methods in logical containers. So, you’ll sometimes end up with a very large class and the only means of logical separation of code is to write comments.
This takes me back to the days of ASP and PHP where you separated the logic by comments because you would write the code in blocks for interpretation by the ASP/PHP web server engine. I can’t imagine I’m the only one finding this a problem, and I’m sure that Microsoft is aware of the issues it causes.
Maybe there is a registry setting that tells which file types Visual Studio is allowed to do collapsible regions in. I haven’t found the answer on the web, but If I do, I’ll post it here.