forwarding a request from a specific ip

B

Brian Henry

I want to be able to forward any request from my one site to another site
based on the IP address... kind of like denying access to the site if an IP
is a certain one if they try to access any page on it and forward it to like
google.com or something, how would you go about doing this? and can you do
it for ranges also? thanks!
 
S

Scott Allen

Hi Brian:

Have you investigated the Request.UserHostAddress property?
The Response.Redirect method?
 
B

Brian Henry

I have, and put it into the Begin Request of the global.asax file trying to
forward any requests at the beginning of the request if it was in a list of
IP's but it doesn't seem to work at all.
 
B

Brian Henry

from global.asax

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)

' Fires at the beginning of each request

If Request.UserHostAddress = "68.70.115.112" Then

Response.Redirect("http://www.google.com")

End If

End Sub



now i know that should work, but it doesn't for some reason... when i step
through the project that doesn't even seem to fire when a request is made on
the site for some reason
 
J

Juan T. Llibre

Try the same thing in Sub Session_OnStart





Brian Henry said:
from global.asax

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)

' Fires at the beginning of each request

If Request.UserHostAddress = "68.70.115.112" Then

Response.Redirect("http://www.google.com")

End If

End Sub



now i know that should work, but it doesn't for some reason... when i step
through the project that doesn't even seem to fire when a request is made
on the site for some reason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top