P
PatP
We have a site that gets many requests for nonexistent pages, files and
folders. We want those requests redirected to the index page. However, for
static files (i.e. images and some other extensions) we do not want to
redirect and in that case want to return nothing.
We had been using the 404 error page to redirect but need to discriminate
the type of file being requested so that we do not return a page when an
image is required.
We'd also like to avoid the round trip of the redirect as performance is an
issue.
We are using Windows Server Web 64 bit and IIS7.
We tested some changes to the <handlers> section in web.config that is used
with IIS7 and were actually able to cause the desired behavior. However
documentation on the <handlers> element's <add> sub-element is sketchy at
best. So is documentation for existing httpmodules that can be specified in
<add> sub-element modules= parameter.
I am familiar with the default configuration. We made a few changes and here
is what seemed to work:
<!-- 082108 Handle known firstlook static files (1 - 9) as they had
been under StaticFile mapping with path="*" -->
<add name="StaticFile1" path="*.jpg" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile2" path="*.jpeg" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile3" path="*.gif" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile4" path="*.css" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile5" path="*.png" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile6" path="*.js" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile7" path="*.swf" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile8" path="*.vbs" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile9" path="*.ocx" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile" path="*" verb="*"
type="content.DefaultHttpHandler, content" modules="" scriptProcessor=""
resourceType="Either" requireAccess="Read" allowPathInfo="false"
preCondition="" responseBufferLimit="4194304" />
We took a survey of static files that our site used and elevated them above
the final add (path="*" verb="*") so that their handling was unchanged. Then
we changed the final (i.e. default or catch-all) add so that it used what is
a do-nothing httphandler (empty ProcessRequest method body).
We've tried some things that did not work and even experienced some site
hangs after deployment so we rolled back. This latest attempt will be tested
more thoroughly but it would be nice to understand more about this area.
Specifically, how does modules= parameter of the add sub-element work in the
context of the handler mappings?
Should only HttpModules be specified there?
Do any custom modules need to be registered?
What does it even mean to specify an HttpModule for a given handler mapping?
Would an HttpModule specified there be a replacement? Would the only
HttpModules in use be the ones specified without any others being implied?
This seems to be an entirely new context for HttpModules with very little if
any explanation as to how it works.
Also, why do some of the default add elements not specify any type=
parameter. In that case which HttpHandler is used?
If there is anyone out there with a firm understanding of this area then
whatever illuminationcan be provided would be most appreciated. I've Googled
til my fingers bled and there's not much there. Microsoft must know because
they have the source.
We just hope they are in a sharing mood....
Thanks!
folders. We want those requests redirected to the index page. However, for
static files (i.e. images and some other extensions) we do not want to
redirect and in that case want to return nothing.
We had been using the 404 error page to redirect but need to discriminate
the type of file being requested so that we do not return a page when an
image is required.
We'd also like to avoid the round trip of the redirect as performance is an
issue.
We are using Windows Server Web 64 bit and IIS7.
We tested some changes to the <handlers> section in web.config that is used
with IIS7 and were actually able to cause the desired behavior. However
documentation on the <handlers> element's <add> sub-element is sketchy at
best. So is documentation for existing httpmodules that can be specified in
<add> sub-element modules= parameter.
I am familiar with the default configuration. We made a few changes and here
is what seemed to work:
<!-- 082108 Handle known firstlook static files (1 - 9) as they had
been under StaticFile mapping with path="*" -->
<add name="StaticFile1" path="*.jpg" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile2" path="*.jpeg" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile3" path="*.gif" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile4" path="*.css" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile5" path="*.png" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile6" path="*.js" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile7" path="*.swf" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile8" path="*.vbs" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile9" path="*.ocx" verb="*" type=""
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="" resourceType="Either" requireAccess="Read"
allowPathInfo="false" preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile" path="*" verb="*"
type="content.DefaultHttpHandler, content" modules="" scriptProcessor=""
resourceType="Either" requireAccess="Read" allowPathInfo="false"
preCondition="" responseBufferLimit="4194304" />
We took a survey of static files that our site used and elevated them above
the final add (path="*" verb="*") so that their handling was unchanged. Then
we changed the final (i.e. default or catch-all) add so that it used what is
a do-nothing httphandler (empty ProcessRequest method body).
We've tried some things that did not work and even experienced some site
hangs after deployment so we rolled back. This latest attempt will be tested
more thoroughly but it would be nice to understand more about this area.
Specifically, how does modules= parameter of the add sub-element work in the
context of the handler mappings?
Should only HttpModules be specified there?
Do any custom modules need to be registered?
What does it even mean to specify an HttpModule for a given handler mapping?
Would an HttpModule specified there be a replacement? Would the only
HttpModules in use be the ones specified without any others being implied?
This seems to be an entirely new context for HttpModules with very little if
any explanation as to how it works.
Also, why do some of the default add elements not specify any type=
parameter. In that case which HttpHandler is used?
If there is anyone out there with a firm understanding of this area then
whatever illuminationcan be provided would be most appreciated. I've Googled
til my fingers bled and there's not much there. Microsoft must know because
they have the source.
We just hope they are in a sharing mood....
Thanks!