易截截图软件、单文件、免安装、纯绿色、仅160KB

ASP.NET post访问外网接口获取数据

方法一:
 string postData = string.Format("a=1&b=2");   //post传递参数
        Stream outstream = null;
        Stream instream = null;
        StreamReader sr = null;
        HttpWebResponse response = null;
        HttpWebRequest request = null;
        Encoding encoding = Encoding.Default;
        byte[] data = encoding.GetBytes(postData);
        // 准备请求
       
            // 设置参数
            request = WebRequest.Create("http://www.baidu.com") as HttpWebRequest;
            CookieContainer cookieContainer = new CookieContainer();
            request.CookieContainer = cookieContainer;
            request.AllowAutoRedirect = true;
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = data.Length;
            outstream = request.GetRequestStream();
            outstream.Write(data, 0, data.Length);
            outstream.Close();
            //发送请求并获取相应回应数据


相关文档:

asp.net性能优化的几个方面

c#(或vb.net)程序改进
1、使用值类型的ToString方法
  在连接字符串时,经常使用"+"号直接将数字添加到字符串中。这种方法虽然简单,也可以得到正确结果,但是由于涉及到不同的数据类型,数字需要通过装箱操作转化为引用类型才可以添加到字符串中。但是装箱操作对性能影响较大,因为在进行这类处理时,将在托管堆中 ......

asp.net的常用代码

 
0.用session判断是否登陆
if(Session["login"] == null)
   {
    Response.Redirect("error.aspx");
   }
1. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open('*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"')</s ......

asp.net输出 png 图像,

asp.net输出 png 32位 图像,带透明alpha。
// pngtest.htm
<html>
<head></head>
<body bgColor="gray">
<img src="png.ashx" />
</body>
</html>
//  png.ashx
<%@ WebHandler Language="C#" Class="Png" %>
using System.Web;
public class Png : IHtt ......

ASP.NET页面刷新方法总结

private void Button1_Click( object sender, System.EventArgs e ) { Response.Redirect( Request.Url.ToString( ) ); } 第二:
private void Button2_Click( object sender, System.EventArgs e ) { Response.Write( " < script language=javascript>window.location.href=document.URL; < /script>" ); } ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号