I have a virtual path provider that serves static files from my virtual file system,is it possible to configure the IIS to server static files through my virtual path provider or do I need to create a custom static file handler?
Asked
Active
Viewed 1,802 times
5
1 Answers
1
If I read correctly say you wanted to handle static files with the extesion pac, that is MyFile.pac from your virtual site.
Open IIS7 and go to your virtual site, in the features view double click MIME Types, then click Add.. and put in your extension and an appropriate MIME type, such as "text/plain".
This is a IIS way of doing it but like you say it could be done with a custom static file handler.
(this is assuming your static files have an extension that are not being dealt with already, as many are)

dove
- 20,469
- 14
- 82
- 108
-
What I want to achieve is that when I request a file that is located in a special directory such as http://localhost/myvirtualdirectory/foo.txt I want my vpp to deliver the file via a static file handler. The file type can be .jpg, .gif or really any file type. So my question is, is there a static file handler built-in in the .NET framework that can handle this for me or do I need to build my own static file handler? – marcus Mar 04 '11 at 12:22
-
@Marcus there is a wildcard static file handler and many specific ones. It's more the realm of IIS. Text files will be handled no problem by IIS. Or is there something you want to do while handling them? – dove Mar 04 '11 at 13:08
-
@Marcus don't forget to address with @dove so I'd be alerted to your comment. – dove Mar 04 '11 at 13:09
-
@dove yes I want the ability to intercept and/or deliver static files (jpg, gif, etc) via my virtual path provider. So when I access the path localhost/myvpp/foo.jpg my vpp verify that the file exists and returns true then I want a static file handler to say; hey I know that the virtual file exists because the FileExists method in your vpp says that it does, so therefor I serve it to your browser. – marcus Mar 04 '11 at 13:36
-
@dove Strangely enough, I found a thread with exactly the same subject, unfortunately, his configuration does not work for me. I'm running .net 4, asp.net mvc 3 and my application pool runs in integrated pipeline mode. This is how my web.config looks like for the dropbox section http://pastebin.com/WC0kZYqJ , do you have any ideas? – marcus Mar 05 '11 at 08:40
-
I ended up creating my own wildcard static file handler and configured it for a specific location in my web.config. The handler response to every request made to this specific location and then i open the file from my vpp and send it to the browser. – marcus Mar 06 '11 at 08:42
-
1@Marcus: If your solution is valid (which I can't think of any other way to do it than the way you described) you should include it as a new Answer and mark it as Accepted. – Jon Adams Oct 19 '11 at 14:48