ashx一般处理程序使用HttpRequest发起HTTP请求

https://www.cnblogs.com/Images/OutliningIndicators/None.gif
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif
private string RequestPost( string Url, string Context) //两个参数分别是Url地址和Post过去的数据
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif {
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif string PageStr =string.Empty;
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif Uri url = new Uri(Url);
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif byte[] reqbytes =Encoding.ASCII.GetBytes(Context);
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif try
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif {
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif req.Method = "post";
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif req.ContentType = "application/x-www-form-urlencoded";
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif req.ContentLength = reqbytes.Length;
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif Stream stm = req.GetRequestStream();
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif stm.Write(reqbytes, 0, reqbytes.Length);
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif stm.Close();
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif HttpWebResponse wr = (HttpWebResponse)req.GetResponse();
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif Stream stream = wr.GetResponseStream();
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif StreamReader srd = new StreamReader(stream,Encoding.GetEncoding( "gb2312"));
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif PageStr += srd.ReadToEnd();
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif stream.Close();
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif srd.Close();
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif }
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif catch (Exception e)
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif {
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif PageStr += e.Message;
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif }
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif return PageStr;
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif }
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif
https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif
https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif
//多个参数配置
协议名----http://
域名
站点名---aaa
页面名(文件名)
参数------id=5&name=kelli
1、完整url (协议名+域名+站点名+文件名+参数) string url=Request.Url.ToString(); url= http://www.test.com/aaa/bbb.aspx?id=5&name=kelli
2、站点名+页面名+参数 string url=Request.RawUrl;(或 string url=Request.Url.PathAndQuery;) url= /aaa/bbb.aspx?id=5&name=kelli
3、站点名+页面名 string url=HttpContext.Current.Request.Url.AbsolutePath; (或 string url= HttpContext.Current.Request.Path;) url= aaa/bbb.aspx
4、域名 string url=HttpContext.Current.Request.Url.Host; url= www.test.com
5、参数 string url= HttpContext.Current.Request.Url.Query; url= ?id=5&name=kelli
6、站点名
System.Web.HttpContext.Current.Request.ApplicationPath
url协议+域名+端口号+站点名
stringurl = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Host + ":" + System.Web.HttpContext.Current.Request.Url.Port +
System.Web.HttpContext.Current.Request.ApplicationPath;