时间:2016-02-15 21:53 来源: 我爱IT技术网 作者:佚名
欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【asp.net 截取Http请求的实现代码】,下面是详细的讲解!
asp.net 截取Http请求的实现代码
public class HttpServer : IDisposable
{
private HttpListener listener;
public void Start()
{
listener=new HttpListener();
listener.Prefixes.Add("http://localhost/");
listener.AuthenticationSchemes=AuthenticationSchemes.IntegratedWindowsAuthentication | AuthenticationSchemes.Anonymous;
listener.Start();
listener.BeginGetContext(GetContext, null);
}
private void GetContext(IAsyncResult ar)
{
HttpListenerRequest Request;
HttpListenerResponse Response;
try
{
HttpListenerContext ctx=listener.EndGetContext(ar);
Request=ctx.Request;
Response=ctx.Response;
//setup waiting for the next request
listener.BeginGetContext(GetContext, null);
}
catch (InvalidOperationException)
{
return;
}
catch (HttpListenerException)
{
return;
}
try
{
var sw=new StreamWriter(Response.OutputStream);
sw.Write(@"<html><body><p>你的请求已经被截取</p></body></html>");
sw.Flush();
}
finally
{
Response.OutputStream.Flush();
Response.Close();
}
}
public void Dispose()
{
if (listener !=null)
listener.Stop();
}
}
关于asp.net 截取Http请求的实现代码的用户互动如下:
相关问题:
答: >>详细
相关问题:
答: >>详细
相关问题:
答: >>详细
- 【asp】asp.net url重写浅谈-net-url重写
- 【创建】ASP.NET Web API教程 创建域模型的方法详
- 【页面打印】关于ASP.NET页面打印技术的常用方法
- 【MVC5】MVC 5 第一章 创建MVC 5 web应用程序-net
- 【服务器】asp.net页面状态管理cookie和服务器状
- 如何取消.net后台线程的执行
- 【asp】asp.net 分页链接方法-net-分页链接
- 【AS】ASP.NET设计网络硬盘之文件夹实现-SP--PN-N
- 【采集】asp.net采集网页图片的具体方法-网页-图
- 【ajax】asp.net下ajax.ajaxMethod使用方法-ajaxM
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
