1)需要在Windows系统中安装IIS服务器,具体安装方法可以根据自己的操作系统百度搜索,如“Win10 IIS”之类。
2)安装后可以在C盘看到诸如“C:\inetpub\wwwroot”之类的目录,这个目录就是本地虚拟服务器的根目录,任何放入其中的网页都可以在虚拟服务器上访问。访问方法是在浏览器中输入”localhost”或者“127.0.0.1”,默认会打开iisstart.html文件,显示一张图片。如果在其中新建诸如index.html之类的文件,按照默认的优先级可以首先默认请求index.html。具体文件请求的默认次序可以在IIS管理器中配置,一般在“控制面板”——“管理工具”——“Internet 信息服务(IIS)管理器”,选择好服务器后,右边点选“默认文档”即可修改。
3)可以从一个简单的网页开始练习:
新建index.html,内容为:
<!DOCTYPE html>
<html>
<head>
<meta charset=”UTF-8″>
<title></title>
</head>
<body>
<form action=”process.asp” method=”get”>
姓名:<input type=”text” name=”username”><br>
密码:<input type=”password” name=”password”><br>
<input type=”submit” value=”OK”>
</form>
</body>
</html>
接受请求的process.asp文件为:
<%
uname=ucase(request.querystring(“username”))
pw=ucase(request.querystring(“password”))
Response.Write(“姓名:”&uname&”<br>”)
Response.Write(“密码:”&pw)
%>
将两个文件一起放到wwwroot目录中,即可浏览器打开测试
4)两个问题:
如果index网页采用post方式提交,则process.asp文件修改为:
<%
uname=ucase(request.form(“username”))
pw=ucase(request.form(“password”))
Response.Write(“姓名:”&uname&”<br>”)
Response.Write(“密码:”&pw)
%>
如果汉字参数存在乱码,可以尝试以下处理方案
<%
Session.CodePage=65001
Response.Charset=”UTF-8”
%>
<%
uname=ucase(request.form(“username”))
pw=ucase(request.form(“password”))
Response.Write(“姓名:”&uname&”<br>”)
Response.Write(“密码:”&pw)
%>
完整演示如图所示: