1. 程式人生 > 其它 >ASP.NET aspx獲取Url引數, 獲取表單提交引數, 獲取Get引數, 獲取Post引數

ASP.NET aspx獲取Url引數, 獲取表單提交引數, 獲取Get引數, 獲取Post引數

ASP.NET aspx獲取Url引數, 獲取表單提交引數, 獲取Get引數, 獲取Post引數
https://www.eyuee.com/article/1596721993/592.html

ASP.NET aspx獲取Url引數, 獲取表單提交引數, 獲取Get引數, 獲取Post引數

Default.aspx頁面中實現

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 using System;   namespace WebApplication5 {
    /// <summary>     /// Default.aspx     /// </summary>     public partial class Default : System.Web.UI.Page     {         protected void Page_Load(object sender, EventArgs e)         {             if (!IsPostBack)             {                 // 獲取Url引數, Get請求引數                 
// http://127.0.0.1/Default.aspx?id=1                 string id = Request.QueryString["id"];                   // 獲取表單提交引數, Post請求引數                 string username = Request.Form["username"];                 // 為了防止有中文亂碼的問題, 最好在獲取時進行Url解碼操作                 username = System.Web.HttpUtility.UrlDecode(Request.Form[
"username"].ToString());             }         }     } }