![9a674796e635bcdd811d1d0b40534b5d.gif](https://img-blog.csdnimg.cn/img_convert/9a674796e635bcdd811d1d0b40534b5d.gif)
ASP即Active Server Pages,是Microsoft开发的服务器端脚本环境,可用来创建动态交互式网页。ASP简单、直观,易于理解。在计算机专业和物联网专业的小学期课程中,我们就将使用HTML+JS+ASP+Access的组合,创建一个小型网站程序。
![422a7d3f611166a454bf9c113575248b.gif](https://img-blog.csdnimg.cn/img_convert/422a7d3f611166a454bf9c113575248b.gif)
我们执行ASP脚本需要服务端的运行环境。而本文就将以我们使用最广泛的Windows 10为例,带领大家一同安装所需的运行环境。
安装IIS
![25b938f169c8337a673e2340e167d904.png](https://img-blog.csdnimg.cn/img_convert/25b938f169c8337a673e2340e167d904.png)
![05660310c3bb9ec8bd1394d1f7aa2d48.png](https://img-blog.csdnimg.cn/img_convert/05660310c3bb9ec8bd1394d1f7aa2d48.png)
右击开始按钮,选择应用与功能。
![8dbfe48d83af497dac4c3d9a674419e9.png](https://img-blog.csdnimg.cn/img_convert/8dbfe48d83af497dac4c3d9a674419e9.png)
向下翻页,找到“相关设置”,
点击“程序与功能”。
![c7e3d9f198d952eb956acc0997c59193.png](https://img-blog.csdnimg.cn/img_convert/c7e3d9f198d952eb956acc0997c59193.png)
点击“启用或关闭Windows功能”。
![2a220995e0d4378658b56187464bca4c.png](https://img-blog.csdnimg.cn/img_convert/2a220995e0d4378658b56187464bca4c.png)
找到Internet Information Services,在其前面的框里点击,此时框变成填充状态(黑方块)。
![0030251e529b0813aa3d2c9c68eae20e.png](https://img-blog.csdnimg.cn/img_convert/0030251e529b0813aa3d2c9c68eae20e.png)
依次点开"IIS"、“万维网”、“应用程序开发功能”前的加号,找到"ASP",将其打勾。
点击确定,开始安装。
![63186089cb7520f1ae9135db48369afe.png](https://img-blog.csdnimg.cn/img_convert/63186089cb7520f1ae9135db48369afe.png)
安装完成后,可在开始菜单的Windows管理工具中找到IIS管理器。
![97db22626bbf56316967d0020b28e18f.png](https://img-blog.csdnimg.cn/img_convert/97db22626bbf56316967d0020b28e18f.png)
IIS的默认网站根目录地址位于C:\inetpub\wwwroot。
![ea09cb0e50a726c3f52103b73bffad0f.png](https://img-blog.csdnimg.cn/img_convert/ea09cb0e50a726c3f52103b73bffad0f.png)
笔者编写了"Hello, World"代码,放到了网站根目录里。
![96ba0613e4c381d24c2641b34f630336.png](https://img-blog.csdnimg.cn/img_convert/96ba0613e4c381d24c2641b34f630336.png)
在浏览器中访问这个页面( http://localhost/hello.asp ),成功打印出"Hello, World" 。
![ae581a4d6a4ed57ddc6d784918132018.png](https://img-blog.csdnimg.cn/img_convert/ae581a4d6a4ed57ddc6d784918132018.png)
下面简单介绍一下ASP的配置。
![7d887afe0a0a3cf360ed42fb0e20ab4f.png](https://img-blog.csdnimg.cn/img_convert/7d887afe0a0a3cf360ed42fb0e20ab4f.png)
打开IIS管理器,在左侧选择Default Web Site,点击右侧的"ASP",就可以进入配置页面了。
![9cec6334d78c9d04ecd4bae01b1b360c.png](https://img-blog.csdnimg.cn/img_convert/9cec6334d78c9d04ecd4bae01b1b360c.png)
★这里主要说两个配置★
①将错误发送到浏览器
打开这个选项,就可以把ASP执行的错误信息打印到浏览器中,方便调试。不过生产环境可千万别打开哦~
②启用父路径
如果在ASP代码中使用了这个ASP文件的父目录的文件,那么就需要打开这个选项才能正常运行。
安装Access Database Engine
![25b938f169c8337a673e2340e167d904.png](https://img-blog.csdnimg.cn/img_convert/25b938f169c8337a673e2340e167d904.png)
![550a016b8b498fdca5215de9dc9186db.png](https://img-blog.csdnimg.cn/img_convert/550a016b8b498fdca5215de9dc9186db.png)
浏览器打开下载地址
https://www.microsoft.com/en-us/download/details.aspx?id=54920
点击Download,下载Access Database Engine 2016。
![2da54b9460e9d229655797685e49a211.png](https://img-blog.csdnimg.cn/img_convert/2da54b9460e9d229655797685e49a211.png)
在弹出的选框中选择64位,点击Next下载并安装。
安装成功后即可在ASP中使用Access数据库(accdb格式)。
![f17998658b416478249502330a27d643.png](https://img-blog.csdnimg.cn/img_convert/f17998658b416478249502330a27d643.png)
这里,笔者创建了一个数据库的访问例子。
![517dd4ec3f25e014e60ef5c98c93ef10.png](https://img-blog.csdnimg.cn/img_convert/517dd4ec3f25e014e60ef5c98c93ef10.png)
访问这个页面,可以看到,页面成功打印出来了保存在数据库中的信息。
![ae581a4d6a4ed57ddc6d784918132018.png](https://img-blog.csdnimg.cn/img_convert/ae581a4d6a4ed57ddc6d784918132018.png)
然而,我们刚才这样做有一个问题,那就是我们没有给数据库文件的写权限,也就是说我们只能读取,却不能写入。
写入这个数据库要求对数据库文件本身和数据库所在文件夹都有写权限。为了简单,我们直接建立一个新文件夹放置数据库,并加上写权限。
![80b0705efd7e14ae4cb72753362c200d.png](https://img-blog.csdnimg.cn/img_convert/80b0705efd7e14ae4cb72753362c200d.png)
右键新文件夹,属性,选择安全选项卡。
![b85b752249adf8e07580a6ec856c1d11.png](https://img-blog.csdnimg.cn/img_convert/b85b752249adf8e07580a6ec856c1d11.png)
这里我们粗暴的给了任何用户(Everyone)的权限。
点击添加,输入everyone,确定。
![01abcdfbeaa8371fba0025bc57dd5f5c.png](https://img-blog.csdnimg.cn/img_convert/01abcdfbeaa8371fba0025bc57dd5f5c.png)
在everyone的权限框中的"完全控制"的"允许"处打勾,设置权限设置,确定。
此时把数据库文件放到这个文件夹里面,就可以在ASP正常读写这个数据库了。
到了这里,基本的环境配置就已经结束了,这也意味着,大家Web开发的旅途马上就要启程了。
那么,祝大家代码一遍通过,没有BUG!
本文作者所用的示例数据库和脚本可以在这里下载哦。
https://everything411.top/files/HelloASP.zip
THE
END
排版 | everything411
![20a413965491925868c9db0bdff2296b.gif](https://img-blog.csdnimg.cn/img_convert/20a413965491925868c9db0bdff2296b.gif)
编写 | everything411
![a87d90118c26e50f8b8de45f3596cf7e.gif](https://img-blog.csdnimg.cn/img_convert/a87d90118c26e50f8b8de45f3596cf7e.gif)
审核 | 养生阿皮
![20a413965491925868c9db0bdff2296b.gif](https://img-blog.csdnimg.cn/img_convert/20a413965491925868c9db0bdff2296b.gif)
![7607ea7dd986b4c093440bd41fff1a61.png](https://img-blog.csdnimg.cn/img_convert/7607ea7dd986b4c093440bd41fff1a61.png)