1. /// <summary>
  2. /// 跨页面POST数据
  3. /// </summary>
  4. public class RemotePost : Dictionary<string, string>
  5. {
  6. /// <summary>
  7. /// 提交HTTP POST请求
  8. /// </summary>
  9. /// <param name="url">请求目标地址</param>
  10. /// <param name="isBackable">可选参数,是否可通过浏览器回退按钮退到本提交页面</param>
  11. public void Submit(string url, bool isBackable = true)
  12. {
  13. HttpResponse response = System.Web.HttpContext.Current.Response;
  14. response.Clear();
  15. if (isBackable)
  16. {
  17. response.Write("<html><head></head><body onload=\"pageload();\">");
  18. response.Write("<script language=\"javascript\">function pageload(){if(document.getElementById('hidBackUrl').value.length==0){document.getElementById('hidBackUrl').value=document.referrer;document.form1.submit();}else{location.href=document.getElementById('hidBackUrl').value;}}</script>");
  19. response.Write("<input id=\"hidBackUrl\" type=\"hidden\" value=\"\" />");
  20. }
  21. else
  22. {
  23. response.Write("<html><head></head><body onload=\"document.form1.submit();\">");
  24. }
  25. response.Write(string.Format("<form name=\"form1\" method=\"post\" action=\"{0}\">", url));
  26. foreach(string key in this.Keys)
  27. {
  28. response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\" />", key, this[key]));
  29. }
  30. response.Write("</form></body></html>");
  31. response.End();
  32. }
  33. }
使用方法非常简单

  1. var post = new CtripSZ.Frameworks.Net.RemotePost();
  2. post.Add("GUID", Guid.NewGuid().ToString());
  3. post.Submit("./Receive.aspx");
 
 
原文地址:http://blog.chinaunix.net/uid-20049824-id-3348117.html

C# POST数据到指定页面,并跳转至该页面的更多相关文章

  1. s实现指定时间自动跳转到某个页面

    --js实现指定时间自动跳转到某个页面 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo ...

  2. [Xcode 实际操作]九、实用进阶-(24)使用Segue(页面的跳转连接)进行页面跳转并传递参数

    目录:[Swift]Xcode实际操作 本文将演示使用Segue(页面的跳转连接)进行页面跳转并传递参数. 参照结合:[Xcode10 实际操作]九.实用进阶-(23)多个Storyboard故事板中 ...

  3. [HTML]js实现页面跳转,页面A跳到另一个页面B.以及页面传值(中文)

    要实现从一个页面A跳到另一个页面B,js实现就在A的js代码加跳转代码 JS跳转大概有以下几种方式: 第一种:(跳转到b.html)<script language="javascri ...

  4. H5如何实现关闭当前页面,跳转到新页面?

    小程序有此功能的跳转方法. 那么H5如何实现该功能?  很简单. location.replace('new.html')  这个方法可以实现 关闭当前页面,跳转到新页面 的效果. 而   windo ...

  5. silverlight 退出当前页面、跳转到主页面

    1.退出当前页面 private void imgExit_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (Message ...

  6. 手机设备访问PC页面如果跳转到手机页面?

    //例如:iphone访问www.baidu.com自动跳转到wap.baidu.com,只需在pc端模版页面引入以下js代码//pc zhuan mobile var mobileAgent = n ...

  7. 使用iframe框架时,实现子页面内跳转到整个页面,而不是在子页面内跳转

    首先先来描述一下我所遇到的问题,我在一个首页的index.jsp页面中用到了iframe框架,见下图 在iframe中引入jsp页面的路径,是几个iframe框架组合成的一个完整的页面,但是他们的存在 ...

  8. session过期后iframe页面如何跳转到parent页面

    session过期后如果在iframe里操作就会返回到login.html,可是这个页面还在iframe里面如果再次登陆就会出现iframe嵌套的现象,我们这样来解决. 在login.html里面加上 ...

  9. 解决angular单页面页面底部跳转到新页面滚动条不在顶部的问题

    以上jquery,下面js this.router.events.subscribe((event) => { document.body.scrollTop=0; }); 另一种写法 impo ...

  10. web页面直接跳转至其他页面

    <script type="text/javascript">window.location.herf="../../XXXXX.aspx";< ...

随机推荐

  1. codevs2034 01串2

    /* 一开始认为是个水题 直接模拟 没想到只得了50分 一看数据吓niao了 模拟妥妥的TLE 实在不好优化了0.0(最快O(m)) 然后借鉴别人的 DP+神奇的输出 DP:状态:f[i][j] 前i ...

  2. Windows Azure上的Odoo(OpenERP)-2.在Ubuntu虚拟机上部署Odoo(OpenERP)

    创建虚拟机的步骤在这里就不再赘述了,请参考上一篇博文. 首先用下述命令将Ubuntu系统进行更新: 1. sudo apt-get update 2. sudo apt-get upgrade 3. ...

  3. 5事件DOM零级事件跟DOM二级事件

    事件的行为传播,行为本身跟事件绑定没有关系:1.全新认识事件(某一个具体的行为)->行为本身:浏览器天生自带的一些行为操作->click,mouseover(mouseenter),mou ...

  4. Linq101-Miscellaneous

    using System; using System.Collections.Generic; using System.Linq; namespace Linq101 { class Miscell ...

  5. redisbook笔记——redis内存映射数据结构

    虽然内部数据结构非常强大,但是创建一系列完整的数据结构本身也是一件相当耗费内存的工作,当一个对象包含的元素数量并不多,或者元素本身的体积并不大时,使用代价高昂的内部数据结构并不是最好的办法. 为了解决 ...

  6. .net处理页面的抓取数据

    //要抓取数据的页面路径 string url = "http://www.scedu.net/banshi/used-car/lower-secondary-education/middl ...

  7. Oracle11G安装

    1.安装Oracle 记住要设置好密码 不要忘了 解锁scott(注意一定要解锁)账户, 去掉前面的绿色小勾,输入密码.同样可以输入平常用的短小的密码,不必非得按oracle建议的8位以上大小写加数字 ...

  8. mybatis审查要点

    1.where条件遗漏情况 <select id="findActiveBlogLike" resultType="Blog"> SELECT * ...

  9. jquery ajax(5)form表单序列化

    form表单序列化<script type="text/javascript"> $(function(){ $("#send").click(fu ...

  10. Delphi笔记(GL_Scene四轴飞行器模型)

    有了前的一篇做铺垫,已经简单的说了GL_Scene的下载安装和一个简单的实例制作.现在就要开始制作一个3D的模型了,具体的步骤就不再这里多说了,直接上图和代码吧! [第一版]先看一下最开始的版本吧,比 ...