博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
重定向redirect与跳转forward区别
阅读量:6912 次
发布时间:2019-06-27

本文共 1432 字,大约阅读时间需要 4 分钟。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DemoResponse.aspx.cs" Inherits="WebApplication1.DemoResponse" %>        
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 DemoResponse : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {        }        protected void Button1_Click(object sender, EventArgs e)        {            //Response为响应对象             Response.Write("hello!!!");            //Response.End();//结束响应            //Response.Write("
hi"); Response.Flush(); //清除缓冲区,并将缓冲区的内容发送出去 Response.Write("
你好!!"); Response.Clear();//清除缓冲区 Response.Write("
hi!!!"); } protected void Button2_Click(object sender, EventArgs e) { //重定向 /*forward是服务器内部重定向,程序收到请求后重新定向到另一个程序,客户机并不知道; redirect则是服务器收到请求后发送一个状态头给客户,客户将再请求一次, 这里多了两次网络通信的来往。当然forward也有缺点,就是forward的页面的路径如果是相对路径就会有些问题了。 forward后,地址栏显示的信息不改变 而Redirect后,是开始了一个新的Http请求,因此地址栏是redirect后的地址。 forward保存了相关的状态信息,而redirect不保存信息。 */ Response.Redirect("login.aspx");//告诉浏览器,让它去访问Login.aspx页 } }}

 

转载于:https://www.cnblogs.com/xiaz/p/5242505.html

你可能感兴趣的文章
漂亮的title提示信息
查看>>
bootstrap-分页-禁用和激活状态
查看>>
文件的递归遍历
查看>>
我的友情链接
查看>>
Python读写CSV文件
查看>>
EBB-7、认识bash
查看>>
CentOS 5.8 64位 源码安装mysql5.5.28
查看>>
windows下后台运行程序
查看>>
传统的MapReduce框架慢在那里
查看>>
Linux下修改Mysql的用户(root)的密码
查看>>
萌新的Linux学习之路(十二)---软件安装
查看>>
2012数学建模A题
查看>>
20个java异常处理最佳实践
查看>>
centos架设pptp服务:并测试windos客户端、Linux客户端!
查看>>
【c#】BackgroundWorker类的使用方法
查看>>
【NetApp】启用smb2.0
查看>>
Nginx与django+uwsgi成功勾搭的始末(上)
查看>>
创业的国度
查看>>
001作业题
查看>>
字节字符转换流
查看>>