• request请求对象实例


    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DemoRequest.aspx.cs" Inherits="WebApplication1.DemoRequest" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1"  runat="server">
        <div>
        
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
                Text="request上的属性" />
            <br />
            用户名:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <br />
            <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="登录" />
        
        </div>
        </form>
    </body>
    </html>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace WebApplication1
    {
        public partial class DemoRequest : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                //request为请求对象。请求者给我带来的一系列信息 
    
                Response.Write("请求的路径:" + Request.Path);
                Response.Write("<br/>请求者的ip:" + Request.UserHostAddress);
                Response.Write("<br/>请求者的主机名:" + Request.UserHostName);
                Response.Write("<br/>请求者的浏览器:" + Request.Browser.Browser);
                string p = Request.Path;//请求的路径 这里得到的是虚拟路径(站点路径 )
                string s = Request.MapPath(p);//能将虚拟路径 转换为物理路径(磁盘路径)
                Response.Write("<br/>物理路径:" + s);
    
    
            }
    
            protected void Button2_Click(object sender, EventArgs e)
            {
                //获取提交的数据
               string un= Request["TextBox1"];//get 方式与post提交的都可以
               Response.Write("<br/>request得到的值:" + un);
              un= Request.QueryString["TextBox1"]; //get方式提交过来的值 
              Response.Write("<br/>QueryString得到的值:" + un);
              un = Request.Form["TextBox1"]; //post方式提交过来的
              Response.Write("<br/>Form得到的值:" + un);
    
            }
        }
    }
  • 相关阅读:
    <转>性能测试浅谈
    Linux内存机制以及手动释放swap和内存
    Jmeter(十二)_打印时间戳
    Jmeter(二十一)_脚本参数化与内存溢出的解决方案
    Jmeter(五)_函数
    爬虫利器_you-get
    Jmeter(九)_获取JDBC响应做接口关联
    JMeter(十三)-代理服务器录制脚本
    JMeter(十)-正则表达式关联
    JMeter(十四)-自动生成测试报告
  • 原文地址:https://www.cnblogs.com/xiaz/p/5242486.html
Copyright © 2020-2023  润新知