Re: Restrict page by IP
- From: "Juan T. Llibre" <nomailreplies@xxxxxxxxxxx>
- Date: Thu, 7 Jun 2007 13:46:35 -0400
There's also an extraneous "Else"...
This should cover it, if placed in the Page_Load event :
Dim RemoteAddr as String = Request.ServerVariables("REMOTE_ADDR")
If instr(RemoteAddr, "192.168.0") Then
Response.Redirect ("/Login/entry_denied.asp")
End If
Mark's code is simpler, though.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"David Wier" <davidwier@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:u6R8kmSqHHA.3740@xxxxxxxxxxxxxxxxxxxxxxx
Just put this logic at the very first of the Page_Load routine, in your ASPX page
change Dim RemoteAddr to:
Dim RemoteAddr as String
remove the <% %> tags and you're good to go
--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://iWritePro.com
"Billy Bob" <not@xxxxxxxxxxxxx> wrote in message news:e5W6$gSqHHA.3228@xxxxxxxxxxxxxxxxxxxxxxx
Working in ASP/VBSCRIPT, I have a snippet that denies access to a page if the user's IP does not
belong to the local network:
<%
Dim RemoteAddr
RemoteAddr = Request.ServerVariables("REMOTE_ADDR")
If instr(RemoteAddr, "192.168.0") Then
Else Response.Redirect ("/Login/entry_denied.asp")
End If
%>
I need to apply this to a ASPX page. Can you help me with the syntax?
.
- Follow-Ups:
- Re: Restrict page by IP
- From: Billy Bob
- Re: Restrict page by IP
- References:
- Restrict page by IP
- From: Billy Bob
- Re: Restrict page by IP
- From: David Wier
- Restrict page by IP
- Prev by Date: Re: HttpContext.Current.Application
- Next by Date: Re: inputing, paging, sorting, a large text file
- Previous by thread: Re: Restrict page by IP
- Next by thread: Re: Restrict page by IP
- Index(es):
Relevant Pages
|