zoukankan      html  css  js  c++  java
  • Request类和Response类

    来源:http://www.cnblogs.com/aidd2008/archive/2009/02/02/1382556.html

    对象
    Request派生自HttpRequest类,从客户端获取信息,浏览器的种类,用户输入表单的数据,Cookies,客户端认证等
    对应的Response.Write  负责处理前者获取的东西

    表单提交
    get
    ...?xxx=value&yyy=value
    post
    浏览器请求的HTTP标头中返回服务器

    get
    string id = Request.QuerryString["name"];
    string age = Request.QuerryString["age"];
    post
    string id = Request.Form["name"];
    string age = Request.Form["age"];

    Request.Params["name"];//自己查提交方式
    Request.Params["age"];
    Request["name"];
    Request["age"];

    Response.Write(Request.RequestType );//传数据的方式


    网页虚拟路径  Request.ServerVariables["url"]
    Request.RawUrl
    实际路径  Request.ServerVariables["path_translated"]
    Request.PhysicalPath
    服务器名 Request.ServerVariables["server_name"]
    服务器IP Request.UserHostAddress

    浏览器是否支持背景音乐 Request.Browser.BackgroundSounds
    浏览器是否支持框架 Request.Browser.Frames
    浏览器什么系统 Request.Browser.Platform

    HttpCookie nc = new HttpCookie("newcookie");
    nc.Values["name"] = "aidd";
    nc.Values["age"] = "22";
    nc.Values["dt"] = DataTime.Now.ToString();

    HttpCookie getcook = Request.Cookies["newcookie"];
    Response.Write(getcook.Values["age"]);

    Response来自HTTPResponse类,回应客户端,告诉浏览器回应内容的报头,服务器端的信息以及输出指定的内容
    ContentType描述内容类型的字符串,格式type/subtype,内容分类,特定内容类型。
    默认 text/html
    Response.ContentType = "image/gif";
    Response.Clear();//删除缓冲区里的HTML输出,只删除预备输出的那些,并不删除Response头信息
    Response.ClearHeaders();只头
    Response.ClearContent();全部删除
    Response.Expires = 5;       页面过期时间5分钟,重新下载,分钟
    Response.ExpiresAbsolute = DateTime.Now.AddHours(8);  为了兼容asp,设置缓存移出的绝对时间,当前时间加8小时,后面是一个时间格式的。
    不指定,则在午夜over
    Response.Buffer = false;          页面是否缓冲输出,默认true
    Response.Flush();立即缓冲输出
    Response.End();立即输出,并停止当前页的执行,下面的不要了
    Response.Redirect(http://aidd2008.cnblogs.com);重定向
    String aa = Server.MapPath("~/app_data/a.xml").ToString() ;
    Response.WriteFile(aa );
    Response.Write( Server.HtmlDecode( Server.HtmlEncode("<script>alert('去过了吗?')</script>") ) );编码后解码,相当于两个都没有

  • 相关阅读:
    Struts 2
    spring中的发布订阅
    win10 安装mysql5.7.36
    Spring Boot如何使用HikariCP连接池详解
    ascii 和 byte以及UTF-8的转码规则
    计算机基础之 二进制与十进制
    VMWare VMNet 8 的配置使用
    IDEA中运行kotlin程序报错:Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6
    在Kotlin中使用Kotlin/java注解及注意事项
    关于Vue2.0,Express实现的简单跨域
  • 原文地址:https://www.cnblogs.com/leon916/p/1423518.html
Copyright © 2011-2022 走看看