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();
//发送请求并获取相应回应数据
相关文档:
我主要用来跟踪后台的一些情况,我用的是一个第三方插件,很好用的
log4net
具体使用如下:
Web.config配置:
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<log4net>
&nbs ......
在Asp.net中,从A页面中弹出B页面,在B页面中选择数据后,关闭并将数据更新到A页面,是一种常用的方式。只是我对Javascript不熟悉,所以捣鼓了一下午,终于有了一点成绩。
测试项目有两个页面:Default.aspx及Default2.aspx,在Default.aspx页面上有一个TextBox1及一个Button1,Button1用于触发Default2.aspx,TextBox ......
在asp.net中使用fckeditor ,页面使用them时,通过编辑器上传图片或文件提示
"Using themed css files requires a header control on the page"
解决办法:
在fckeditor的web.config文件中做如下修改
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<pages styleSheet ......
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>" ); } ......