I was doing some work with a database driven version of the Virtual Earth Tile Service HTTPHandler, and needed to do some debugging. I ran into some odd behavior which took some time to track down, so hopefully this saves someone else some time.
To use a HttpHandler, you need to register it in your web.config. Here's what I had :
<system.web> <httpHandlers> <add verb="*" path="*.ve" type="DBTileHandler" /> </httpHandlers> </system.web>
This just simply routes requests for anyoldthing.ve to the DBTileHandler class, which must implement IHTTPHandler. Very simple.
Typically I open websites "from file" in Visual Studio as this seems to work a little more consistently with VisualSVN (I think this is some issue with my box, as others on my team have no problems opening via IIS). As a result, when I debug the site, it spins up the ASP.NET Development Webserver (aka "Cassini"), and binds to a random port (e.g 2323). Then the site launches on http://localhost:2323/site. All is well and you can step through your aspx pages.
However, you can't debug http handlers by just starting up the site from Visual Studio. You need to change the Start Action of the project to "Don't open a page. Wait for a request from an external application" as shown below.
Then once you start the web site, and it builds, you need to use Debug --> Attache to Process, and select aspnet_wp.exe.
At this point you can make requests to your handler, and breakpoints will be hit - curiously you attach to the aspnet_wp.exe process even if you are running the site through Cassini.
So, I was happily debugging my tile handler, and got everything worked out, tile were showing up in my VE Map and all was well in the world. Then I went to try it through IIS. Doh! No tiles!
Firebug showed me that the requests were correct, but they were returning with 404's
I went back and fired it up in Cassini, and got tiles. IIS - no tiles. Cassini tiles. IIS no tiles.
This was quite odd - why would my handler work in one case and not the other? Clearly there is something different between the web servers but what?
To make a long dull story involving much Googling shorter, the answer is that Cassini automatically maps file extensions specified in the Http Handlers section of the web.config, but IIS requires that the file extension mapping be applied explicitly in IIS. Obviously.
There are two ways to solve this issue:
1) Add the .ve extension to IIS and map it to the aspnet_isapi.dll
or
2) change the extension in your configuration to a type already handled by ASP.NET - such as ashx or aspx.
I chose the latter because it will simplify the deployment of the site. All I did was tack ".aspx" on the end of the path attribute in my web.config and all was working again.
I'm Dave and this is my blog. I'm usually writing about .NET Software Development, ArcGIS, or Agile Practices, but other stuff does creep in from time to time. I hope you find something of use, and feel free to contact me if you have any questions. You can also check out my profile on LinkedIn
dojo.DTSAgile.com is our technology preview / demo site. As I and my team cook up cool things we post them here.
ArcDeveloper.net is a site that hosts a set of open source projects related to ArcGIS. This includes Tile Cache for .NET (TC4N) and Feature Server for .NET (FS4N). Come over and check it out!
Assembla is a free service that provides Subversion source control, wikis and work Tracking. The ArcDeveloper project is run from here. It rocks. Check them out today.
Agilistas is a LinkedIn group focused on discussing and promoting Agile practices. Everyone is welcome to join in the conversation as we evolve the process of creating software to make it more enjoyable for all involved.