Asp. NET environment to increase the IP filtering function of the website 1th/2 page _ Practical Tips

Source: Internet
Author: User

1. Demand Analysis

Through in-depth communication and communication, confirmed the power plant in the Enterprise website user Access control improvement requirements, the general situation is as follows:

A The website is based on asp.net2.0 implementation and does not allow modification of the source program

B Factory users can directly access all pages of the entire site, employees do not need authentication

c) Outside the factory users can only access the specified page

Clearly, they are adding an IP filtering function to the corporate web site, shutting them out when users outside the factory visit certain sensitive pages. First we need to set up an IP list and a URL list, the former contains all the IP in the factory, which contains all the URLs accessible to the outside of the factory, and the two lists are maintainable; Another core problem is that we need to choose a reasonable way to integrate the developed functional modules into the corporate web site, HttpModules incumbent.

In the ASP.net era, after IIS received the request and dispatched it to Aspnet_isapi.dll, the ASP.net engine began initializing the configured HTTP module (httpmodules) one by one. The correct HTTP handler is then invoked and the requested resource is rendered, and finally the generated token is returned to IIS and the requesting client (as shown in the following figure).

IIS and ASP.net are processing requests

If you want to know more about httpmodules, please check it yourself.

2. Programme design

2.1. Development environment

Programming Language: c#2.0

Development tools: Visual studio.net2008

Operating system: Windows2003 R2

2.2. Overview Design

The core idea of using httpmodules to implement IP filtering is to customize a HttpModule to capture each user request, then obtain the relevant user IP and the requested URL for logical judgment, and redirect the unauthorized request to an error prompt page. The decision logic for HTTP request authorization is:

1 to determine whether the request is from the local computer, it is automatically ignored, otherwise continue;

2 to determine whether the user IP belongs to the intranet (IP list), it is ignored, otherwise continue;

3 to determine whether the requested URL is authorized to access all users, is ignored, or continue;

4 redirects the request to the error prompt page.

Attaching a custom handler to the HttpApplication beginrequest event completes the capture of the HTTP request. In addition, in order to facilitate the maintenance of the program we should run the required parameters (IP list, URL lists, error page paths, and so on) are stored in a specific XML configuration file, and in order to improve efficiency, we also need to perform memory-level caching of the configuration files and optimize the IP and URL matching algorithms appropriately.

Current 1/2 page 12 Next read the full text

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.