How to back up an Access database with a renamed name

Source: Internet
Author: User
Tags httpcontext ole access database backup

There is a problem with Access databases in the background of developing a company's OA system recently.

In order to prevent the database from downloading for malicious people, you need to change the database suffix name aspx (ASP, etc.), and the company insiders need to download the database through IE to backup the database.

Of course, there is not a particularly secure way to hide a database by modifying the file name suffix, after all, the database in M and the ASPX page in K can be seen as a database or a Web page at a glance. However, it is a simple and easy way to do it.

First of all, simply modifying the database file suffix name aspx does not guarantee that it will not be downloaded, and you can restore the database by downloading the ASPX page and then modifying it back to the suffix name. (As mentioned earlier, it is obvious to see which pages are faked by the database.)

Here you need to do something about this modified file, plus <%%>, and you can have IIS treat it as an ASPX page and return an error instead of downloading it. Can not be simply added, you need to first create a text file containing <%%>, and then add a table in the original database, add an OLE Object field, and then add a record, the contents of the OLE Object field to the previous text created.

Then it's about how your internal people are going to download the database properly. Pass. NET HttpResponse object to the client to enter the database file to implement the download.

To modify an HTTP header:

HttpContext.Current.Response.AppendHeader ("Content-disposition", "Attachment;filename=backup.mdb");

HttpContext.Current.Response.ContentType = "Application/ms-access";

To enter a file to the client:

Long FileSize = new FileInfo (dbpath). Length;

Response.WriteFile (dbpath, 0, FileSize);

That's basically it.

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.