ASP. NET database programming-processing file access permission

Source: Internet
Author: User
Tags mdb database

One MDB database is another file on the hard disk. Therefore, like other files, it will also encounter the same file access license problem. This problem means to read (and write, as you will see later in this book) database files, the application running on the page must have the relevant license to read (and write) the file in Windows.

So far, the reason why the pages in the example can "run normally" is that you are using VWD Web Server, a lightweight program running under the identity of a user running VWD. This means that the VWD Web Server runs for you and you are allowed to read and write the MDB File connected to the page.

However, when running pages under IIS, the situation is a little complicated. In this case, the ASP. NET page runs under the identity of a user account with specific permissions. Under IIS 5.1, this account is "ASPNET ". In IIS 6.0 or later versions, this account is "Network Service" and belongs to a Windows user group called IIS_WPG ("worker process group. To use the Access database in IIS, these accounts must grant the permission to read directories containing MDB files and write permissions as appropriate.

To help you create these licenses, VWD performs additional steps when the database is in the App_Data subdirectory under the application root directory and automatically grants this license to the ASPNET or Network Service account. If you are using VWD to develop pages on the machine, this specific directory will always be granted the correct permission. The App_Data directory also has other advantages, such as preventing any file from responding to the Web browser sending the request. This means that after the MDB file is placed in the local App_Data directory of the application, it can protect these files from being unintentionally or intentionally downloaded by the client of the application. Therefore, we strongly recommend that you save the MDB file to the App_Data directory.

If you must save the MDB file to another place or manually specify the permission for the database directory (for example, you are working on a remote Web server), you can use Windows for ASP.. NET and/or Network Service account configuration license.

To manually set the license, follow these steps:

(1) Use Windows Explorer to browse the folder where the MDB file is located.

(2) Right-click the Directory and select Properties.

(3) Select the Security label and click the Add button.

(4) Add a local ASP. NET account (IIS 5.1) or IIS_WPG group (IIS 6 ).

(5) Click OK and apply the license to this directory.

For more information, see the "Running ASP. NET 1.1 and IIS 6.0" whitepaper:Http://www.asp.net/faq/AspNetAndIIS6.aspx.

 

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