I have an HttpHandler class (implements IHttphandler) where the path defined for the handler in web.config is *.jpg. I am requesting a Jpg image in my page. Within the HTTP Handler I am writing to a file in the filesystem. By mistake I was trying to write to a non existant directory. This should have thrown an exception but the execution simply proceeds.Ofcourse no file is written. But if I give a proper directory the file is written correctly.Is there anything special about HttpHandler Exceptions.
See part of the code
public void ProcessRequest(HttpContext context){
File.WriteAllLines(context.Request.ApplicationPath+@"\"+"resul.log",new string[]{"Entered JPG Handler"});
If I put a breakpoint on the File.WriteAllLines statement and then step over it I can see an exception occurring.
Request.Application returns the application’s virtual application root path on the server. For example: “/YourApp”, as opposed to “C:\inetpub\wwwroot\YourApp.”
What’s likely happening is File.WriteLine(…) is actually writing the file somewhere, probably in the same folder as your web server process.
EDIT: Here’s some of the likely places to check:
if using built-in VS2008 web server
C:\Program Files (x86)\CommonFiles\microsoft shared\DevServer\9.0
if using built-in VS2010 web server
C:\Program Files (x86)\CommonFiles\microsoft shared\DevServer\10.0
if using IIS
C:\Windows\System32\inetsrvorC:\Windows\SysWOW64\inetsrv