473,783 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Restrict page access by IP address

Hi,

I need to restirict access at the page level to a range of IP
addresses. What's the best approach? I thought of building an HTTP
module that could compare the requesting IP with a restricted range,
specified in web.config. Any thoughts?

Thanks,
Chris

Apr 5 '06 #1
7 5319
Use a base Page class which inherits System.Web.UI.P age, and checks the
client IP against the list in the web.config. If you want to save
processing, you can set a Session variable that indicates the IP is fine,
and only call the method if the Session variable is not present.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Chris Fulstow" <ch**********@h otmail.com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
Hi,

I need to restirict access at the page level to a range of IP
addresses. What's the best approach? I thought of building an HTTP
module that could compare the requesting IP with a restricted range,
specified in web.config. Any thoughts?

Thanks,
Chris

Apr 5 '06 #2
Thanks Kevin, that's a great idea. I could first check the IP in
Session_OnStart and set the Session variable, then use Page_Init to
check if the requested page is accessible. If it's not, then send an
HTTP 403 response to the browser. It might just work... :)

Apr 5 '06 #3
You can do it right in IIS.
In the IIS 6.0 Administrator's guide, there's complete instructions.

Open D:\WINDOWS\Help \IIS.chm

and search for "IP addresses, controlling access to applications"

Securing Sites with IP Address Restrictions

You can configure your Web site to grant or deny specific computers,
groups of computers, or domains access to Web sites, directories, or files.

IP address restrictions apply only to IPv4 addresses.

Important : You must be a member of the Administrators group on the local computer to perform
the following procedure (or procedures), or you must have been delegated the appropriate authority.

To grant or deny access to a group of computers
1.. In IIS Manager, expand the local computer, right-click a Web site, directory, or file, and
click Properties.
2.. Click the Directory Security or File Security tab. In the IP address and domain name
restrictions section, click Edit.
3.. Click Granted access or Denied access. When you select Denied access, you deny access to
all computers and domains, except to those that you specifically grant access. When you select
Granted access, you grant access to all computers and domains, except to those that you specifically
deny access.
4.. Click Add.
5.. Click Group of computers.
6.. In the Network ID box, type the IP address of the host computer.
7.. In the Subnet mask box, type the subnet ID for the computer you want grant or deny access to.
8.. Click OK three times.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"Chris Fulstow" <ch**********@h otmail.com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
Hi,

I need to restirict access at the page level to a range of IP
addresses. What's the best approach? I thought of building an HTTP
module that could compare the requesting IP with a restricted range,
specified in web.config. Any thoughts?

Thanks,
Chris


Apr 5 '06 #4
Thanks Juan - it might be that I need to control access to individual
pages, but it might turn out to be the whole site, in which case I'll
definitely use this approach.

Apr 5 '06 #5
You're quite welcome, Chris.

It's always good to know all your options.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"Chris Fulstow" <ch**********@h otmail.com> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
Thanks Juan - it might be that I need to control access to individual
pages, but it might turn out to be the whole site, in which case I'll
definitely use this approach.

Apr 5 '06 #6
Hi I'm working with IIS 5.0 and for some odd reason a single IP address is
not being blocked even though I've denied all users except for a few IP
addresses. I was wondering if in IIS 5.0 I'm able to both grant access to a
certain group of IP addresses as well as deny access to one domain name
without having to write an ISAPI script. Or is it just a "one or the other"
option?

v/r,
reena
"Juan T. Llibre" wrote:
You're quite welcome, Chris.

It's always good to know all your options.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"Chris Fulstow" <ch**********@h otmail.com> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
Thanks Juan - it might be that I need to control access to individual
pages, but it might turn out to be the whole site, in which case I'll
definitely use this approach.


Apr 13 '06 #7
Hi,
I was reading through this and I was wondering if you could restrict page
access by domain name?

v/r,
reena

"Kevin Spencer" wrote:
Use a base Page class which inherits System.Web.UI.P age, and checks the
client IP against the list in the web.config. If you want to save
processing, you can set a Session variable that indicates the IP is fine,
and only call the method if the Session variable is not present.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Chris Fulstow" <ch**********@h otmail.com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
Hi,

I need to restirict access at the page level to a range of IP
addresses. What's the best approach? I thought of building an HTTP
module that could compare the requesting IP with a restricted range,
specified in web.config. Any thoughts?

Thanks,
Chris


Apr 13 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3131
by: Paul | last post by:
Hi all, at present I I've built a website which can be updated by admin and users. My problem, I've combined "log in" and "access levels" to restrict access to certain pages, using the built in "log in" and "user authentication, restrict access to page" features. But I find the after login I constantly get redirected from the restricted pages.
28
6425
by: gc | last post by:
Hi, What is the purpose of the restrict keyword? gc
7
2676
by: tweak | last post by:
Can someone give me a short example as how to best use this keyword in your code? This is my understanding: by definition restrict sounds like it is suppose to restrict access to memory location(s) pointed to, so that only one declared pointer can store that address and access the data in those memory blocks, where I the data in those location(s) can be changed. Is that a correct understanding?
1
2506
by: ccdrbrg | last post by:
I'm having trouble understanding restrict. Can someone provide a layman's explanation. Chad
21
6529
by: Niu Xiao | last post by:
I see a lot of use in function declarations, such as size_t fread(void* restrict ptr, size_t size, size_t nobj, FILE* restrict fp); but what does the keyword 'restrict' mean? there is no definition found in K&R 2nd.
2
2633
by: Frederick Gotham | last post by:
I'm going to be using an acronym a lot in this post: IINM = If I'm not mistaken Let's say we've got translation units which are going to be compiled to object files, and that these object files will be supplied to people to link with their own projects. Here's a sample function in one of the object files: void Func(int const *const p) {
6
2381
by: rainy6144 | last post by:
Does the following code have defined behavior? double *new_array(unsigned n) { double *p = malloc(n * sizeof(double)); unsigned i; for (i = 0; i < n; i++) p = 0.0; return p; }
3
3599
by: =?Utf-8?B?R1ROMTcwNzc3?= | last post by:
Hi there, I've got the standard Dreamweaver restrict access to page behaviour below – <% ' *** Restrict Access To Page: Grant or deny access to this page MM_authorizedUsers="1,2,3" MM_authFailedURL="index.asp" MM_grantAccess=false If Session("MM_Username") <"" Then If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
1
2036
by: ameifan83 | last post by:
Hi, May I know how do I restrict access from a certain country? I know I can do it by restricting ip address using .htaccess. But I just want to restrict just one page, not the whole domain. How can I do it? Appreciate any help here. Thanks. Regards, Dan
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.