search
HomeDatabaseMysql TutorialASPASP.NET网站中怎么防止Access数据库被别人下载

如何防止Access数据库下载是一个很老的话题了,网上的讨论也比较多。这里我们给出几种在ASP.NET下防止Access数据库被下载的方法。 我们这里假设Access数据库名字为 test.mdb。 1、把数据库放在WEB目录外 如你的网站目录是D:www,你可以把数据库放到D:data 这

 如何防止Access数据库下载是一个很老的话题了,网上的讨论也比较多。这里我们给出几种在ASP.NET下防止Access数据库被下载的方法。

我们这里假设Access数据库名字为 test.mdb。

1、把数据库放在WEB目录外

如你的网站目录是D:www,你可以把数据库放到D:data 这个文件夹里,然后修改网站程序中的数据库连接字串地址部分为:"D:datatest.mdb" ,这样数据库可以正常调用,但是无法下载的,因为它不在网站目录里。

假设在web.config中配置数据库连接字符串。例如:

2、把数据库放在App_Data系统文件夹下

从.Net2.0开始有App_Data目录来专门存放数据文件,它可以用来放Access,SQL Server Express、XML等数据文件。数据库文件放到App_Data文件夹的好处就是可以防止被下载。而对于连接字符串数据库的文件位置可以使用DataDirectory关键来表示它的物理路径,从而在获取连接字符串的时候不再需要使用Server.MapPath()转换。

假设在web.config中配置数据库连接字符串。例如:

               

|DataDirectory|就是代表的app_data文件夹。

3、重命名数据库文件

将你的 Access 重命名 *.asax:因为 ASP.NET 的处理机制中,默认情况下,对这样的请求是直接拒绝的。按照这个思路,还可以把 Access 重命名为 *.config,*.vb, *.cs 等等。

4、配置IIS,添加.mdb文件类型映射

添加.mdb的扩展映射这个方法就是通过修改IIS设置来实现。只需2个步骤。

1. 配置IIS,将.mdb文件类型映射到ASP.NET ISAPI。

以windows 2003为例,点击“开始”-》运行-》输入“inetmgr” 回车,打开“Internet 服务管理器”。在某一个网站上单击鼠标右键-》点击“属性” 弹出此站点的属性对话框。点击“主目录”选项卡,点击“配置”按钮,则会显示“应用程序配置”对话框。点击“添加”增加一个映射,这时会显示一个对话框,要你输入可执行文件:“C:WINDOWS Microsoft.NET Framework v2.0.50727 aspnet_isapi.dll”;输入扩展名:“.mdb”。如下图所示

ASPASP.NET网站中怎么防止Access数据库被别人下载 三联

2. 配置asp.net的web.config文件,将.mdb文件类型映射到HttpForbiddenHandler HTTP handler。

使asp.net应用程序.mdb文件类型映射到HttpForbiddenHandler HTTP 句柄。为了达到这上步,必须将下面的配置加到Web.config文件中

5、添加ACCESS防下载字段

该方法的原理是:将数据库的扩展名变成.aspx格式,从远程访问这个文件的时候,IIS服务器就会把它当成aspx程序来执行,而我们之前在ACCESS数据库中插入了“”标记中才能执行,所以就会出现 “缺少脚本关闭标记” 的500错误,别人就无法下载ACCESS数据库了。如果只是简单的在数据库的文本或者备注字段加入“

1、先创建一个表,在SQL命令窗口内输入如下内容:“create table [notdown]([notdown] oleobject)”

然后点击工具栏中的“!”(运行),这样,就会在当前数据库内创建一个“notdown”表,其中的字段名称为“notdown”,字段类型为“OLE对象”。 如图1

ASP\ASP.NET网站中怎么防止Access数据库被别人下载


(图1)

2、将SQL查询窗口中的内容更改为如下命令:“insert into [notdown](notdown) values (0x3C25)”

这一句的意思是向“notdown”表的“notdown”字段中插入“0x3C25”数据(“0x3C25”为字符“

ASP\ASP.NET网站中怎么防止Access数据库被别人下载


(图2)

执行完毕后,再次查看数据库中的“表”,,就会发现其中已多了一个“notdown”表,打开后字段显示的是“长二进制数据” 如图3

ASP\ASP.NET网站中怎么防止Access数据库被别人下载


(图3)

admin10000.com 这里已经做好的防下载数据表notdown,你可以直接下载粘贴到自己数据库中使用。notdown数据表

提示1:无论是ASP网站中还是ASP.NET网站,对于直接把Access数据库后缀直接改为.asp和.aspx,用FlashGet等下载工具都照下不误,不能起到防下载作用。
提示2:第5种方法通常用在ASP+ACCESS网站中。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Adding Users to MySQL: The Complete TutorialAdding Users to MySQL: The Complete TutorialMay 12, 2025 am 12:14 AM

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

Mastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMay 12, 2025 am 12:12 AM

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

MySQL: String Data Types and Indexing: Best PracticesMySQL: String Data Types and Indexing: Best PracticesMay 12, 2025 am 12:11 AM

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

MySQL: How to Add a User RemotelyMySQL: How to Add a User RemotelyMay 12, 2025 am 12:10 AM

ToaddauserremotelytoMySQL,followthesesteps:1)ConnecttoMySQLasroot,2)Createanewuserwithremoteaccess,3)Grantnecessaryprivileges,and4)Flushprivileges.BecautiousofsecurityrisksbylimitingprivilegesandaccesstospecificIPs,ensuringstrongpasswords,andmonitori

The Ultimate Guide to MySQL String Data Types: Efficient Data StorageThe Ultimate Guide to MySQL String Data Types: Efficient Data StorageMay 12, 2025 am 12:05 AM

TostorestringsefficientlyinMySQL,choosetherightdatatypebasedonyourneeds:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseTEXTforlong-formtextcontent.4)UseBLOBforbinarydatalikeimages.Considerstorageov

MySQL BLOB vs. TEXT: Choosing the Right Data Type for Large ObjectsMySQL BLOB vs. TEXT: Choosing the Right Data Type for Large ObjectsMay 11, 2025 am 12:13 AM

When selecting MySQL's BLOB and TEXT data types, BLOB is suitable for storing binary data, and TEXT is suitable for storing text data. 1) BLOB is suitable for binary data such as pictures and audio, 2) TEXT is suitable for text data such as articles and comments. When choosing, data properties and performance optimization must be considered.

MySQL: Should I use root user for my product?MySQL: Should I use root user for my product?May 11, 2025 am 12:11 AM

No,youshouldnotusetherootuserinMySQLforyourproduct.Instead,createspecificuserswithlimitedprivilegestoenhancesecurityandperformance:1)Createanewuserwithastrongpassword,2)Grantonlynecessarypermissionstothisuser,3)Regularlyreviewandupdateuserpermissions

MySQL String Data Types Explained: Choosing the Right Type for Your DataMySQL String Data Types Explained: Choosing the Right Type for Your DataMay 11, 2025 am 12:10 AM

MySQLstringdatatypesshouldbechosenbasedondatacharacteristicsandusecases:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseBINARYorVARBINARYforbinarydatalikecryptographickeys.4)UseBLOBorTEXTforlargeuns

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.