透過 Request.QueryString (GET) 與 Request.Form (POST) 接收使用者提交的表單資料,是 ASP 互動網頁的基礎。
<form method="get" action="process.asp">
名字: <input type="text" name="fname"><br>
姓氏: <input type="text" name="lname"><br><br>
<input type="submit" value="送出">
</form>
process.asp?fname=Bill&lname=GatesRequest.QueryString("fname")<body>
歡迎 <%= Request.QueryString("fname") %> <%= Request.QueryString("lname") %>
</body>
Request.TotalBytes 限制)Request.Form("fname")<body>
歡迎 <%= Request.Form("fname") %> <%= Request.Form("lname") %>
</body>
value 輸出。<!-- process.asp 驗證失敗時導回表單 -->
<% If Not IsValid Then %>
<form method="post" action="process.asp">
名字: <input name="fname" value="<%= Server.HTMLEncode(Request.Form("fname")) %>">
<span class="error"><%= errorMsg %></span>
...
</form>
<% End If %>
安全提醒:輸出使用者輸入至 HTML 時務必 Server.HTMLEncode 防止 XSS;資料庫操作使用參數化查詢 (ADO Command/Parameters) 防止 SQL Injection。