Prevent users from accessing XML files on the server through their browser addresses

Source: Internet
Author: User

Recently when doing a project, because many are called interfaces, so basically do not need the database, in order to save a small amount of validation data, the use of XML is chosen to store. after uploading the project to the server, it is found that the client can access the XML path on the browser by entering the server-side corresponding XML paths, because the XML contains information that uniquely identifies the user, so it does not want the user to be able to view the file, so it searches the web for several solutions.

programme One: encrypts the data in the XML. This approach is really simple, but it doesn't do what I want to prohibit users from accessing this file.

Scenario Two: Modify the XML file extension name, for example, change. xml to. Do. This method can also effectively prohibit user access, but my project in the XML references too much, the change is more cumbersome, so also have to look for the next solution.  

Scenario Three: First add an XML map to IIS, the mapped program is C:\WINNT\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll

Then add the following code to the Web. config

<add verb= "*" path= "*.xml" type= "System.Web.HttpNotFoundHandler"/>

This allows the server to return a 404 (File not found) page when the user accesses the XML

This method seems to be a perfect solution to the problem I want to end, but! My \microsoft.net\framework\v1.1.4322 folder is empty, but found a v4.0.30319 this folder, thinking my is. NET Framework4.5, and then quoted, but found in the Web. config add code, page hints httphandlers This may be wrong, but how to change all no fruit, can only feel that the file was added wrong. So a good study of IIS, found the final solution.

Scenario four: In IIS, there is a request filtering, open look, there is a file extension, you can add the specified extension name inside, thereby prohibiting access to such files.

Want to go or the final Solution (scenario four) is relatively simple, but think about the data security perspective, or should be important data encryption after the data into the database or other data storage files.

      



Prevent users from accessing XML files on the server through their browser addresses

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.