<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DemoResponse.aspx.cs" Inherits="WebApplication1.DemoResponse" %>

<!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="方法" />
<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 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("<br>hi");
Response.Flush(); //清除缓冲区,并将缓冲区的内容发送出去
Response.Write("<br/>你好!!");
Response.Clear();//清除缓冲区
Response.Write("<br/>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页
}
}
}

重定向redirect与跳转forward区别的更多相关文章

  1. springMVC中的redirect和forward区别?

    1.forward在跳转后可以取到message值,redirect在跳转后无法取到message值. 2.forward跳转后地址栏URL不会改变,而redirect会改变.

  2. nodejs 重定向 (redirect + writeHead(Location))

    参考: Node.js实现301.302重定向服务 Express URL跳转(重定向)的实现:res.location()与res.redirect() 一 方式1 index.js var htt ...

  3. .htaccess技巧: URL重写(Rewrite)与重定向(Redirect)

    URL重定向是.htaccess的重头戏,它可以将长地址转为短地址.将动态地址转为静态地址.重定向丢失的页面.防止盗链.实现自动语言转换等.笔者觉得难点是在正则表达式的运用和理解上. 实现所有这些神奇 ...

  4. .htaccess技巧: URL重写(Rewrite)与重定向(Redirect) (转)

    目录 Table of Contents 一.准备开始:mod_rewrite 二.利用.htaccess实现URL重写(rewrite)与URL重定向(redirect) 将.htm页面映射到.ph ...

  5. 拦截Response.Redirect的跳转并转换为Js的跳转

    有一个很常见的需求,某个页面需要用户登录才能访问,或者某个操作需要用户登录 这就需要检测用户登录,一般是使用Ajax去检测是否登录,当用户未登录时跳转到登录页面 那么问题来了···· 有的时候我们跳转 ...

  6. forward内部跳转 和redirect重定向跳转的区别

    1.从地址栏显示来说 forward是服务器请求资源,服务器直接访问目标地址的URL,把那个URL的响应内容读取过来,然后把这些内容再发给浏览器.浏览器根本不知道服务器发送的内容从哪里来的,所以它的地 ...

  7. 请求转发(forward)和请求重定向(redirect)的区别(转)

    作者:@haimishasha本文为作者原创,转载请注明出处:https://www.cnblogs.com/haimishasha/p/5952129.html 用户向服务器发送了一次HTTP请求, ...

  8. 转发(Forward)和重定向(Redirect)的区别

    转发是服务器行为,重定向是客户端行为. 转发(Forword) :通过RequestDispatcher对象的forward(HttpServletRequest request,HttpServle ...

  9. 转发forward和重定向redirect的区别

    本质区别:转发只发送一次请求,重定向发送两次请求. 转发: request.getRequestDispatcher("/HiServlet").forward(request,r ...

随机推荐

  1. Maven打jar包

    <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactI ...

  2. [ubuntu] Can not run OpenProj on Ubuntu

    Download openproj from http://sourceforge.net/projects/openproj/ Yes, you can only download the rpm ...

  3. [ThinkPHP] 输出、模型的使用

    # # ThinkPHP 3.1.2 输出和模型使用 # 讲师:赵桐正 微博:http://weibo.com/zhaotongzheng   本节课大纲: 一.ThinkPHP 3 的输出      ...

  4. intall vs code in elementary os

    Open Terminal & Type Install Ubuntu Makesudo apt-get install ubuntu-make Microsoft Visual Studio ...

  5. MKCOL not allowed

    通过TortoiseSvn操作GitHub的时候出现下图提示: 原因:尝试在根目录创建新的文件夹(文件),貌似是不被允许的行为 解决:只能在trunk 或者 branches下再新建文件夹(文件)

  6. xcode简介

    Xcode 是苹果公司开发的编程软件,是开发人员建立OS X 和 iOS 应用程序的最快捷方式.Xcode 具有统一的用户界面设计,编码.测试.调试都在一个简单的窗口内完成. Xcode前身是继承自N ...

  7. js编写规范

    JavaScript编码规范 Bug----33条 1. 不要使用’==’和’!=’,使用’===’和’!==’替代 等级:Major 原因:==和!=在判断值相等前会判断类型是否相等.这容易因为类型 ...

  8. UINavigationController(转)

    UINavigationController是IOS编程中比较常用的一种容器view controller,很多系统的控件(如UIImagePickerViewController)以及很多有名的AP ...

  9. android 学习随笔六(网络要求及配置)

    android在4.0之后已经不允许在主线程执行http请求了. 主线程阻塞,应用会停止刷新界面,停止响应用户任何操作,耗时操作不要写在主线程   只有主线程才能修改UI ANR异常:Applicat ...

  10. linux设备驱动归纳总结(十三):1.触摸屏与ADC时钟【转】

    本文转载自:http://blog.chinaunix.net/uid-25014876-id-119723.html linux设备驱动归纳总结(十三):1.触摸屏与ADC时钟 xxxxxxxxxx ...