ASP.NET Server对象

Server.HtmlEncode() 执行文本代码
Server.HtmlDecode()可以将代码显示 而不是执行它 但是ASP.NET会认为恶意 我们可以将aspx代码开头添加validateRequest=false

Server.MapPath() 将虚拟路径转换为绝对路径 例如C:/Music

Server.UrlEncode() 将代码以Url方式编码 用途:url拼接的时候如果值有& 我们可以urlEncode()传入
Server.UrlDecode() 解码

Server.Transfer() 页面跳转(服务器上执行)
原理:服务器停止解析本页面,保存此页面,是页面跳转到M2.aspx

Server.Excute() 保存此页面跳转之前的数据 跳转到m2.aspx执行 再回来执行剩余的M1.aspx 结果给浏览器

Server.Transfer()和Response.Redirect() 的区别
transfer是服务器请求 m1页面跳转url 直接在服务器端进行执行(同一个页面跳转 浏览器地址不变)
而Redirect是让客户端向服务器发送跳转请求 执行跳转 服务器应答给客户端浏览器 浏览器进行解析

原文地址:https://www.cnblogs.com/ZaraNet/p/9433771.html