Search code examples
dnsrequesthttpmodule

Can I find out what domain made a request that triggered an HttpModule?


How do I find out from within an HttpModule what domain made a particular request?

Say I only want to allow site1.com and site2.com to use images from my server, how do I check that it is them making the request?


Solution

  • There's no way to do this in every case. Consider that UrlReferrer may not be set. Also, consider that you could be called by a client that does not have a DNS address.

    Instead, you should consider configuring IIS to authenticate using user certificates. If you've only got a small number of sites calling you, generate a certificate, register it with IIS and map to the user you want, then give the certificates to those two machines to be installed on them.