views:

77

answers:

2

Is there a way to programmatically know when someone is using the Default Document feature of IIS to access my page (that is, the name of my .ASPX isn't in their URL anywhere)?

+1  A: 

I don't think there's a way to do this. If the default document feature is used, IIS just puts the document name into the URL before passing it to ASP.NET.

What are you trying to accomplish with this? You can turn default documents off if you like.

John Saunders
My Application_BeginRequest fires some logic whenever the requested file can't be found on disk. When they ask for the default document, that logic is firing (IIS7, and Request.Path doesn't reflect the .aspx filename at all). I'd love to add an exception for when the user is using Default Document to get to a page that *does* exist.
lance
The logic that fires when the file can't be found really has nothing to do with 404-type stuff, but maybe I should put that logic in my 404 handler page. That way, the Default Document scenario would never fire that code.
lance
@lance: I think that if you're getting a request without the filename, then default document is off. At least that would be true in IIS6 and below, and I didn't realize it had changed so much in IIS7.
John Saunders
Yeah.. in IIS 7, the filename is the name of the virtual, as Brian's said in his answer. In Cassini (and IIS6, trusting you), it's the default filename.
lance
+1  A: 

Hey,

The only way I can think of is check the URL (to see if it's requesting http://localhost/virtual/ instead of http://localhost/virtual/default.aspx) and consider that the default document...

Not a feature for MVC or if you have url rewriting... and I don't know if an IIS feature for this either, unless for some reason it was added as a module and available via IIS 7...

Brian