正在中止线程错误?在asp.net? [英] Thread was being aborted Error ? In asp.net?

查看:170
本文介绍了正在中止线程错误?在asp.net?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Web应用程序中,我使用code,下载这是上传documnet,这是写在数据列表项命令事件,但它那给人像线程已被中止的错误,你可以帮我解决这个问题,谢谢。我的code是作为休耕。

 保护无效dtlstMagazine_ItemCommand(对象源,DataListCommandEventArgs E)
{
   尝试
   {
    objItMagBe.TitleId = Convert.ToInt32(e.CommandArgument);
    DTS =新的DataSet();
    DTS = objItMagBL.GetMagzineByTitleID(objItMagBe);
    GetPopularMagazine();    字符串MYFILE =../xxxx/DataFiles/+ dts.Tables [0] .Rows [0] [文件]的ToString()。
    如果(File.Exists(使用Server.Mappath(MYFILE))==真)
    {
        Response.AppendHeader(内容处置,附件;文件名=+ MYFILE);
        Response.TransmitFile(使用Server.Mappath(MYFILE));
        到Response.End();
        Response.Flush();
    }
   }
   抓住
   {    }
}


解决方案

您到Response.End()是最有可能是什么原因造成的。这是因为它是告诉ASP.NET请求是结束了。

什么是例外,哪里.NET觉得异常被抛出从堆栈跟踪?

In web application, i am using code, to download the documnet which is uploaded, which is written in item command event of datalist, but it s giving error like "Thread was being aborted" can you help me to solve this, thank you. My code is as fallows.

protected void dtlstMagazine_ItemCommand(object source, DataListCommandEventArgs e)
{
   try 
   { 
    objItMagBe.TitleId = Convert.ToInt32(e.CommandArgument);
    dts = new DataSet();
    dts = objItMagBL.GetMagzineByTitleID(objItMagBe);
    GetPopularMagazine();

    string Myfile = "../xxxx/DataFiles/" + dts.Tables[0].Rows[0]["Files"].ToString();
    if (File.Exists(Server.MapPath(Myfile)) == true)
    {
        Response.AppendHeader("Content-Disposition", "attachment; filename=" + Myfile);
        Response.TransmitFile(Server.MapPath(Myfile));
        Response.End();
        Response.Flush();
    }
   }
   catch
   {

    }
}

解决方案

Your Response.End() is most likely what is causing that. It is because it is telling ASP.NET that the request is over.

What is the stack trace from the Exception, where does .NET think the exception is being thrown from?

这篇关于正在中止线程错误?在asp.net?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆