Is it possible to programmatically resolve a URL to a file using ASP.NET and IIS? Specifically I’d like the file to be outside of my Virtual Directory (could be anywhere on the local file system). So if a URL comes in like http://mysite/somepicture.jpg I’d like to be able to return c:\mypicture.jpg. I looked into creating an IHttpModule for URL rewriting but that isn’t quite what I need – it’s limited to URLs within the existing site.
Share
You cannot achieve it by URL rewriting as the file is not hosted on your Web site. You should use
Response.WriteFilemethod in anHttpModuleorHttpHandlerto manually stream the file to the user.