1127
.net “正在中止线程”错误
- 分类:
- 评论:0
- 浏览:3513
.net “正在中止线程”错误
做这个网站需要下载软件 可我有不想让 迅雷等工具 下载影响网速.
就做了个限制程序!
可就出现了错误 ! 正在中止线程
程序大致如下:
try
{
sting host = context.Request.UrlReferrer.Host;
if ( 程序判断)
{
context.Response.Clear();
context.Response.ContentType = "application/octet-stream";
context.Response.WriteFile(file.FullName);
context.Response.End();
}
}
catch (Exception e)
{
HttpContext.Current.Response.Redirect("/default.aspx?key=" + e.Message);
context.Response.End();
}
只有 一执行 Try 里面的东西 就一定出错 e.Message=正在中止线程
研究了一下好像是 Try 执行的时候 context.Response.End(); 就出错
不能把context.Response.End();放在 Try 里面
需要写成:
try
{
sting host = context.Request.UrlReferrer.Host;
}
catch (Exception e)
{
HttpContext.Current.Response.Redirect("/default.aspx?key=" + e.Message);
context.Response.End();
}
if ( 程序判断)
{
context.Response.Clear();
context.Response.ContentType = "application/octet-stream";
context.Response.WriteFile(file.FullName);
context.Response.End();
}
本文首发于 炽(MyChy)个人主页 ,本文地址: http://www.jeanwen.com/blog/page/39
发表评论中......
关于精彩评论