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. Android群英传》读书笔记 (1) 第一章 Android体系与系统架构 + 第二章 Android开发工具新接触

    第一章 Android体系与系统架构 1.Dalvik 和 ARTDalvik好比是一辆可折叠的自行车,平时是折叠的,只有骑的时候,才需要组装起来用.ART好比是一辆组装好了的自行车,装好就可以骑了. ...

  2. CentOS7搭建SAMBA服务器实现与WIN10匿名共享文件

    1.安装SAMBA yum -y install samba samba-client samba-common 2.修改文件打开数 vi /etc/security/limits.conf 最后添加 ...

  3. Python之路,Day4 - Python基础4 (new版)

    Python之路,Day4 - Python基础4 (new版)   本节内容 迭代器&生成器 装饰器 Json & pickle 数据序列化 软件目录结构规范 作业:ATM项目开发 ...

  4. Vijos P1325桐桐的糖果计划(有向图双连通分量)

    /*重边不能删 不能删 不能删...*/ #include<iostream> #include<cstdio> #include<cstring> #define ...

  5. 二分图最大匹配(匈牙利算法Dfs模板)

    #include<iostream> #include<cstdio> #include<cstring> #define maxn 2020 using name ...

  6. (转)ThinkPHP3.0 使用分组后路径访问无效的解决方法!

    注意,清除Runtime,就是清除缓存,很重要,妹的,调试了一下午,总是加上Home目录分组就找不到页面,直接放到action下就行,原来是缓存搞得鬼,另外要在入口文件开启‘APP_DEBUG’ 在T ...

  7. MSChart使用之动态生成多个多行ChartArea

    前台代码: <asp:Chart ID=" > <Titles> <asp:Title Name="Title1" runat=" ...

  8. 微信 token 验证

    package org.sxl.weixin; import java.security.MessageDigest; import java.security.NoSuchAlgorithmExce ...

  9. 认识html文件基本结构

    html文件的结构:一个HTML文件是有自己固定的结构的. <html> <head>...</head> <body>...</body> ...

  10. uvalive 5760 Alice and Bob (组合游戏,dp)

    题目链接: http://vjudge.net/problem/viewProblem.action?id=25636 对于>1的堆,必然会被其中一人全部合并. 然后就是二维dp,dp[非1堆的 ...