Forum Moderators: open

Message Too Old, No Replies

Hotlinking/Offsite Image Linking ASP.NET Solution

         

Xylem

5:07 am on May 22, 2003 (gmt 0)

10+ Year Member



In PHP you can use mod_rewrite to check the server headers against the host.

Is there a way to do this in ASP.NET?

Perhaps with the global.asax or web.config?

Is there a way to make sure no one can steal my bandwidth?

Thanks!

jeremy goodrich

10:56 pm on May 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



2 days, no ideas - I'll see if I can round up an ASP / IIS guru for you (or at least somebody with a solution).

Xylem

12:15 am on May 24, 2003 (gmt 0)

10+ Year Member



Thanks alot!

:)

IanTurner

6:58 pm on May 24, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It is definitely not as simple as it is with PHP.

The only methods I have devised at the moment are as follows:

1. Write and install an ISAPI filter to parse the incoming requests.

2. Create a temp_images folder. When a page request comes in you set up a timestamped image in the temp_images folder using the FileSystemObject, this can be written into the page based on the incoming SessionID. You can use the FileSystemObject to clear the images out once they have served there useful purpose.

Xoc

2:26 am on May 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In .net you can create a imaginary file quite easily. Put this into the web.config:


<?xml version="1.0" encoding="utf-8"?>
<configuration>

<system.web>
<httpHandlers>
<add verb="GET,HEAD" path="*.png" type="Namespace.ClassName,ClassName" />
</httpHandlers>
</system.web>

</configuration>

Where Namespace and ClassName are replaced by your namespace and classname. Then create some code that gets called when a png (or whatever) file is called. For example:


Public Class ClassName
Implements IHttpHandler

Public Sub ProcessRequest(ByVal context As System.Web.HttpContext) _
Implements System.Web.IHttpHandler.ProcessRequest

'code here to deliver file

End Sub

httpHandlers are the replacements for ISAPI filters in .NET.