下载管理器程序在asp.net中导致一个奇怪的问题 [英] Download Manager Programs cause a strange Problem in asp .net

查看:45
本文介绍了下载管理器程序在asp.net中导致一个奇怪的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp中有一个奇怪的问题。网络无法通过互联网找到任何解决方案。我有一个页面,为用户打印一封信,并在DB中插入用户的信息。我把代码放在底部。当用户点击插入按钮时,它将数据写入Db,然后创建一个pdf文件进行下载并发送给客户端。但是如果用户用浏览器下载它,一切顺利,但如果下载与互联网下载管理器(我用IDM测试)插入数据库方法重复2-3或4次。你能帮助我吗?!!!



I have a strange problem in asp . net that couldn't find any solution over internet. i have a page that print a Letter for user and insert the info of user in DB. i put the code in the bottom. when user click insert button it write-in the data to Db then create a pdf file for downloading and send to client. but if user download it with browser, everything going well but if download with internet download manager(i test with IDM) the insert in DB Method Repeat for 2-3 or 4 times. can you HELP me?!!!

protected void VacationInserted()
    {
        R1.Load(Server.MapPath("~/App_Data/Report.mrt"));
        ATA.Fill(ADT, User.Identity.Name);
        R1.Dictionary.Variables["Automobile"].Value = ADT.Rows[0]["Model"].ToString();
        R1.Dictionary.Variables["No"].Value = ADT.Rows[0]["No_"].ToString();
        UTA.Fill(UDT, User.Identity.Name);

        R1.Dictionary.Variables["Name"].Value = UDT.Rows[0]["FirstName"].ToString() + " " + UDT.Rows[0]["LastName"].ToString();
        R1.Dictionary.Variables["StartDate"].Value = StartVacationDate.Text;
        R1.Dictionary.Variables["EndDate"].Value = EndVacationDate.Text;
        R1.Dictionary.Variables["Period"].Value = Diff.ToString();
        R1.Dictionary.Variables["Destination"].Value = TxtDestination.Text;
        R1.Dictionary.Variables["LetterNumber"].Value = LDT.Rows[0]["LetterNumber"].ToString();
        R1.Dictionary.Variables["InsertDate"].Value = Converter.Today();
        LTA.Update((((double)LDT.Rows[0]["LetterNumber"]) + 0.01), ((int)LDT.Rows[0]["LetterCount"]) + 1);
        Update_VacRemain();
        if (PrintSelect.SelectedValue == "pdf")
        {
            pdfexport();
        }
    }


    protected void pdfexport()
    {

        MemoryStream ms = new MemoryStream();
        R1.Render();
        Stimulsoft.Report.Export.StiBitmapExportSettings s = new Stimulsoft.Report.Export.StiBitmapExportSettings();
        Stimulsoft.Report.Export.StiPdfExportSettings s1 = new Stimulsoft.Report.Export.StiPdfExportSettings();
        Stimulsoft.Report.Export.StiPdfExportService pdfservice = new Stimulsoft.Report.Export.StiPdfExportService();
        s1.Compressed = true;
        s1.EmbeddedFonts = true;
        s1.ImageCompressionMethod = Stimulsoft.Report.Export.StiPdfImageCompressionMethod.Jpeg;
        s1.ImageQuality = 100;
        s1.SubjectNameString = "Vacation";
        pdfservice.ExportPdf(R1, ms, s1);

        Response.ClearContent();
        Response.ClearHeaders();
        Response.Buffer = true;
        Response.ContentType = "Application/PDF";
        Response.AddHeader("Content-Disposition", "attachment;filename=Print_Vac.pdf");

        ms.Position = 0;
        ms.WriteTo(Response.OutputStream);
        ms.Dispose();


        //// I test this three line in bottom and without them but don't change anything
        Page.Response.End();
        //Response.End();
        //Response.Flush();
    }

    protected void InsertVacation_Click(object sender, EventArgs e)
    {
        LTA.Fill(LDT);
        Start = (DateTime)StartVacationDate.DateValue;
        End = (DateTime)EndVacationDate.DateValue;
        Diff = ((End - Start).TotalDays) + 1;
        TextBox Txt_VacRemainder = (TextBox)DetailsView2.FindControl("Txt_VacRemainder");
        Remain = Convert.ToInt32(Txt_VacRemainder.Text) - Convert.ToInt32(Diff);
        if (Remain < 0)
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "hwa", "a()", true);
        }
        else
        {
            if (Diff < 0)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('...');", true);
            }
            else
            {
                NationalNumber = User.Identity.Name;
                InsertDate = DateTime.Now;
                LetterNumber = Math.Round(float.Parse(LDT.Rows[0]["LetterNumber"].ToString()), 2).ToString();
                VTA.Insert(NationalNumber, InsertDate, Start, End, Remain, true, TxtDestination.Text, Math.Round(float.Parse(LDT.Rows[0]["LetterNumber"].ToString()), 2));
                VacationInserted();
                //TxtDestination.Text = "";
                //Page.ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('...');", true);
            }
        }
    }

推荐答案



我认为由于下载管理器(可能是任何下载管理器),您的代码/事件会被多次调用/触发。您可以检查重复条目,如果条目存在,则只允许下载PDF文件。
Hi,
I think your code / event is getting called / triggered multiple times due to download manager (it could be any download manager). You can check for duplicate entry and if entry exists, then just allow downloading PDF file.


感谢您的回答,我的朋友;

但可以解释更多。

如果你可以把代码片段放在这里...

再次感谢!
thanks for answer,my friend;
but can explanation more.
if you could put code snippet here...
thanks again!


我的项目有同样的问题,idm下载从我的应用程序3次或更多次,我将不得不修复它因为我们想要为我们的客户下载限制计数

可以有人帮忙吗?
I have same problem with my project that the idm download 3 or more times from my app and I will have to fix it because we want download limitation count for our customers
can anybody help ?


这篇关于下载管理器程序在asp.net中导致一个奇怪的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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