简体   繁体   中英

HttpHandler and folder locking problemin IIS7

I have a simple HttpHandler which gets the image file from the specified path in the callig URL. For instance, when this URL: http://www.abc.com/images/imageview.ashx?fileName=ok.jpg is called, it will write the file from the path: d:\\images\\ok.jpg using response.writefile.

Everything works fine, but the folder named images in the web site root path (d:\\inetpub\\wwwroot\\images) is locked and after the first call, I could not rename or delete the folder. I don't use the folder (in the web site root) any where!

I've checked all files for the second folder and they are not in used, only the folder is in used.

When I changed the calling URL to http://www.abc.com/imageview.ashx?fileName=images/ok.jpg the problem resolved.

It seems that IIS7 locks the virtual folder for ashx URL.

Any idea or experience?

It's because the image is resolving most likely relative to the folder the handler is in. Either put an absolute path, like /images/ok.jpg, or on the server call ~/images/ok.jpg to resolve it properly. See more about ~ here, http://weblogs.asp.net/fmarguerie/archive/2004/05/05/avoiding-problems-with-relative-and-absolute-urls-in-asp-net.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM