如何防止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”。如下图所示
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
(图1)
2、将SQL查询窗口中的内容更改为如下命令:“insert into [notdown](notdown) values (0x3C25)”
这一句的意思是向“notdown”表的“notdown”字段中插入“0x3C25”数据(“0x3C25”为字符“
(图2)
执行完毕后,再次查看数据库中的“表”,,就会发现其中已多了一个“notdown”表,打开后字段显示的是“长二进制数据” 如图3
(图3)
admin10000.com 这里已经做好的防下载数据表notdown,你可以直接下载粘贴到自己数据库中使用。notdown数据表
提示1:无论是ASP网站中还是ASP.NET网站,对于直接把Access数据库后缀直接改为.asp和.aspx,用FlashGet等下载工具都照下不误,不能起到防下载作用。
提示2:第5种方法通常用在ASP+ACCESS网站中。

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.

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

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.

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

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

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.

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

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


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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
Easy-to-use and free code editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

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
Integrate Eclipse with SAP NetWeaver application server.
