Asp. NET HTML page Access Verification settings Method _ Practical Skills

Source: Internet
Author: User

There may be a lot of friends and I will not be aware of such a problem, in, the access verification features provided by itself (form validation, Passport verification, Windows authentication) do not restrict access to static files (such as HTML, image files, text files, and so on). Anonymous users still have access to these files, even if they are placed in a folder that needs to be validated before they can be accessed. This is because static files are handled by IIS by default, and IIS does not transfer to processing after receiving a request for these files, so the permissions validation in is out of effect. In other words, these documents are not within the jurisdiction of the

So, how do you put these documents under the jurisdiction of the As an example of an HTML file, the easiest way to do this is to change the suffix of the HTML file to ASPX, which is simple and practical, but not formal. Another approach is to set up for IIS and have IIS transfer the processing rights of HTML files to The settings are as follows:

(1) Open IIS, locate the application you want to set up, and open the Properties dialog box.

(2) in the "Virtual directory" tab, there is an "Application Settings", click on the "Settings" button, pop-up New dialog box.

(3) in the "Corresponding" tab, click the "Add" button, add the suffix of the. htm to the handler, and set the settings to reference. aspx.

Once set, access to the HTML file located in the directory you want to verify will go to the login page to prompt the user to log in, stating that access verification is in effect. However, this is still not done because the HTM file error is found after logging in. This involves HttpHandler, because for, this is equivalent to enabling a new file type, but there is no corresponding handler. So, you also need to change the Web.config settings, register a new handler, for HTML files, we can use the ASPX file handler, so set the following:

<system.web> ...

Again, this is a compilation error, because the missing HTM file of the corresponding compiler, and then modify the web.config:

<!--to set up a compiler for files with a suffix of htm, where the compiler for ASPX files-->
<add extension= ". htm" Type= " System.Web.Compilation.PageBuildProvider "/>

This time it accesses this HTML file again, which, as we expect, requires authentication and can be displayed properly. In fact, the core of this problem is the understanding of HttpHandler. In addition, it is said that in IIS7, it is possible to solve this problem by placing the application in a integrated application pool.

If it's not a special requirement or if you want to use an HTML static page, it's easier for individuals to convert HTML to ASPX. Customer deployment does not require too much configuration, some customers are very annoying to deploy the system to configure, so it is easy to do well.

Related Article

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: 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.