First time asking a question here so thanks in advance for your time.
I have this issue:
I am hosting image files (jpg, png, gif) in a folder of my ASP.NET 4.0 application. I know that some people hot link these images as avatars or pictures in other forums, blogs, etc… . I would like to know where.
Searching a little, I found that I can create a custom HTTP handler to serve these files and then have the handler return me a string of the URL where it is accessed from. Unfortunately, I only did basic coding in ASP.NET and this HTTP handler stuff is a little bit over my comprehension. Could anybody point me towards a sample of how it’s done?
Many thanks!
you’ll want to implement IHttpHandler. then in the web.config map this handler to the type(s) of extensions/requests you want to handle. for example all requests for jpg or gif. IHttpHandler has 2 members to implement
IsResuable informs asp.net whether a new handler must be initialized for every request, or if the handler can be cached. Process is where the work is done. from Context you have access to everything in the request and response.