Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an ASP.net web site that allows users to upload files to an upload folder on the server. The site is served by IIS 7.

I have configured the upload folder to not execute any script files that are requested, but how can I configure IIS 7 to serve these files as it would any other static file ONLY for this folder?

Thanks

EDIT

Here is what I have in the Handler Mappings for my upload folder:

Handler Mappings

Here is the web.config for the folder:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <handlers accessPolicy="Read">
        <remove name="TRACEVerbHandler" />
        <remove name="OPTIONSVerbHandler" />
        <remove name="SimpleHandlerFactory-Integrated" />
        <remove name="SSINC-shtml" />
        <remove name="ScriptHandlerFactory" />
        <remove name="SimpleHandlerFactory-ISAPI-2.0" />
        <remove name="HttpRemotingHandlerFactory-soap-Integrated" />
        <remove name="AXD-ISAPI-2.0" />
        <remove name="ASPClassic" />
        <remove name="AssemblyResourceLoader-Integrated" />
        <remove name="HttpRemotingHandlerFactory-rem-Integrated" />
        <remove name="PageHandlerFactory-Integrated" />
        <remove name="ScriptResource" />
        <remove name="SSINC-shtm" />
        <remove name="WebServiceHandlerFactory-ISAPI-2.0" />
        <remove name="SSINC-stm" />
        <remove name="ISAPI-dll" />
        <remove name="PageHandlerFactory-ISAPI-2.0" />
        <remove name="ScriptHandlerFactoryAppServices" />
        <remove name="SecurityCertificate" />
        <remove name="TraceHandler-Integrated" />
        <remove name="UrlRoutingHandler" />
        <remove name="WebAdminHandler-Integrated" />
        <remove name="MvcHttpHandler" />
        <remove name="HttpRemotingHandlerFactory-soap-ISAPI-2.0" />
        <remove name="HttpRemotingHandlerFactory-rem-ISAPI-2.0" />
        <remove name="CGI-exe" />   		
    </handlers>
</system.webServer>
</configuration>

And here is what I get if I request an aspx file that is in my upload folder:

Server Error 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

share|improve this question

2 Answers 2

I had to add a mime type for the file that I want to serve.

I used * to serve unknown file types as application/octet-stream.

share|improve this answer

You probably want a web.config file in this directory that un-maps all the handlers and map "*" to static:

        <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
share|improve this answer
    
See my edit. Thanks. –  Ronnie Overby Aug 4 '09 at 14:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.