locked
Odd HttpHandler behaviour in nested Virtual Directory RRS feed

  • Question

  • User781103784 posted

    I have an HttpHandler configured on my web application, for FLV files. It works well for any FLV files in the web application's virtual directory (IIS6).

    <add verb="*" path="*.flv" type="FlvHandler.FlvStreamHandler, FlvHandler" />

    But I have created another virtual directory, "nested" inside the main one. If I put an FLV file in there and request it, I see an error "Could not load file or assembly 'FlvHandler' or one of its dependencies. The system cannot find the file specified."

    I have correctly set up the .flv file type in the application extensions list of the virtual sub-directory.

    But here's the interesting thing. I go to the folder that the virtual sub-directory points to, add a "bin" folder, and put another copy of the "FlvHandler.dll" in there, and everything is fine!

    So it seems that when a request is made to the sub-directory, IIS is looking at the web.config in the parent directory, but then trying to find the FlvHandler.dll in the sub-directory, not the parent...

    Is there a way around this?

    Thanks for any help.

    Wednesday, May 20, 2009 8:01 AM

Answers

  • User-1136466523 posted

    Hi,

    From your description, it seems that you don't want to deploy the duplicated dll assembly in your application, right?

    But as you described, you have set up a totally new virtual folder which stands for a new application, all codes in that application can't refer to the configuration file in another application, so that's why your applicaiton complains that it can't load the assembly. It can't refer to the assembly in another application.

    I think the reason you created a new virtual folder is to put those flv files in other folders, in order to achieve what you want and avoid deploying duplicated assemblies, you may create the url rewrite function to link to your flv resources, and don't create two virtual folders.

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 24, 2009 11:11 PM

All replies

  • User-1363023537 posted

    In your nested Virtual directorues

    open the Web.config and inside the HttpHandlers section add the folloring

    <
    remove path=".flv" verb="*"/>

    Do it for all nested virtual directories

    or add flvHandler assebly in to bin folder of those nested virtual directories

    Wednesday, May 20, 2009 9:43 AM
  • User781103784 posted

    Thanks for the reply.

    But I still can't quite get it to work.

    Should I be copying the entire web-app's web.config file into the virtual directory, and just substituting the "add path flv" row with the "remove" row? (I slightly amended the given example to <remove path="*.flv" verb="*"/> by the way).

    I tried this, deleting my bin folder with the dll in too, but it doesn't seem to work; that is to say, going to....

    http://...myserver..../VideoServer/Videos/Example.flv (where Example.flv is in the nested virtual directory)

    ...results in a 0-byte file being downloaded. Putting back the bin folder and dll made no difference until the web.config was deleted again.

    Any more help gratefully received :-)

     

    Wednesday, May 20, 2009 10:33 AM
  • User-1363023537 posted

    From your post what I understood is you need to remove the handler from nested virtual directory.
    To do that you need to add <remove path=".flv" verb="*" /> in to <HTTPHandlers>  section of those web.config files

    Wednesday, May 20, 2009 10:47 AM
  • User781103784 posted

    Ah, no, what I'm aiming for is this:

    I have my "VideoServer" web app, which is just a simple .ashx page, and have a handler set up so that it processes any request for FLV files in any of its physical subfolders - a request like so:

    http://...my server.../VideoServer/Physical_Folder_1/Example1.flv

    ...works very well.

    But I want to keep the FLV files elsewhere on the server (ie not in the InetPub folders). So I've added a virtual directory inside the "VideoServer" virtual directory, so I can do requests like so:

    http://...my server.../VideoServer/Virtual_Directory_1/Example1.flv

    ...and this is the bit that doesn't work, unless, inside the physical directory referenced by Virtual_Directory_1, I add a "bin" folder with the VideoServer.dll.

    If I don't do this, the VideoServer.dll, <add verb="*" path="*.flv" type="nnn.VideoServer.FlvStreamHandler" />, cannot be found when the request references the Virtual Directory.

    This isn't ideal of course, as I don't want duplicate .dlls cluttering up the server - hope there's a solution! 

     

     

     

     

     

    Wednesday, May 20, 2009 11:34 AM
  • User-1363023537 posted

    Are you getting any error while accessing virtual_directory_1/example1.flv ?

     

    Thursday, May 21, 2009 3:34 AM
  • User781103784 posted

    Yes, if I don't have a copy of the bin folder and .dll in the virtual sub folder, then the virtual_directory_1/example1.flv request will fail:

    Parser Error Message: Could not load type 'CTC.VideoServer.FlvStreamHandler'.

    <add verb="*" path="*.flv" type="CTC.VideoServer.FlvStreamHandler" />

    So it's evidently finding the web.config file in the main app folder, but then is unable to find the .dll, because it's looking for that in the nested virtual folder, rather than the application's folder.

    Thursday, May 21, 2009 5:06 AM
  • User-1363023537 posted

    Haven't you updated the virtual_directory_1 's web.config for HttpHandlers section remove tag ?

    Or sign that assembly and put into the GAC and let the application start refering it from GAC

    Thursday, May 21, 2009 6:03 AM
  • User781103784 posted

    No, I tried putting a web.config file in the virtual directory yesterday, with a "remove" tag (see third post in thread, above) but it didn't work.

    Besides, I was hoping my virtual directory could remain completely free of web.configs, .dlls and other such things, and purely be a repository for FLVs....

    I guess your GAC suggestion may well be a working solution, but if there are any other alternatives that don't involve doing this, I'd be interested......

    Thursday, May 21, 2009 6:13 AM
  • User-1363023537 posted

    Did you got an error after adding that Remove tag? Can you post that error

    Thursday, May 21, 2009 7:06 AM
  • User781103784 posted

    When I copied the application's Web.config into the virtual directory, then, in that copy, replaced the:

    <add verb="*" path="*.flv" type="FlvHandler.FlvStreamHandler, FlvHandler" />

    with a 

    <remove path="*.flv" verb="*"/>

    ...the flvs still appeared to be present in the virtual directory, but when I attempted to download one I received a 0-byte file (no error).

     

     

    Thursday, May 21, 2009 8:04 AM
  • User-1136466523 posted

    Hi,

    From your description, it seems that you don't want to deploy the duplicated dll assembly in your application, right?

    But as you described, you have set up a totally new virtual folder which stands for a new application, all codes in that application can't refer to the configuration file in another application, so that's why your applicaiton complains that it can't load the assembly. It can't refer to the assembly in another application.

    I think the reason you created a new virtual folder is to put those flv files in other folders, in order to achieve what you want and avoid deploying duplicated assemblies, you may create the url rewrite function to link to your flv resources, and don't create two virtual folders.

    Thanks.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 24, 2009 11:11 PM
  • User781103784 posted

    Hi, thanks for that, that answers my question - certainly explains the (what seemed to be unusual) behaviour.

    I'm a little disappointed in a way, as I liked the "Virtual Folder" solution; it meant that the location of the "Videos" folder in which my app looked for its FLV files could be changed simply by changing the path to which the virtual folder was pointing - easy for an IIS sys-admin person to understand, and better than expecting them to hunt for the appropriate key + path in a .config file....

    I tried doing the same thing by adding a shortcut to the Videos folder, but that didn't work either - so .config file it is, then!

    Thanks for everyone's help. 

    Monday, June 1, 2009 7:13 AM