为什么不重新加载View?

时间:2019-03-19 11:07:06

标签: c# asp.net asp.net-mvc model-view-controller

我想使用CopytoAPResults方法重新加载TvrPrnetExcel,但视图未重定向到Action。我试图使用其他动作。没用方法有效,但是重定向无效。为什么?我该怎么办?:

这是我的动作:

  public ActionResult TvrPrnetExcel()
        {
            return View();
        }

        [HttpPost]
        public async Task<ActionResult> TvrPrnetExcel(FormCollection form)
        {

.........

            using (var db = new TVREntities()){
            

            foreach (string i in ids)
            {
                    var dataID = Convert.ToInt64(i);
                    TVRClip tvrClip = db.TVRClip.Where(x => x.TVRClipDataID == dataID).SingleOrDefault();
                    TVRPublicationProgram publicationProgram = db.TVRPublicationProgram.Where(x => x.TVRProgramID == tvrClip.TVRProgramID).FirstOrDefault();


                        using (var db2 = new MpnetContext())
                        {
                            tbl_APVideoResults APVideoResults = db2.tbl_APVideoResults.Where(x => x.APClipId == dataID).FirstOrDefault();
                            if (APVideoResults != null && APVideoResults.WMVFile != null)
                            {
                                pr.wmvFile = APVideoResults.WMVFile.ToString();
                            }
                            else 
                            {
                                nonexist.Add(dataID);
                                pr.wmvFile = "";
                            }

                        }
                           
                    pr.haberLink = "http://www.prnet.com.tr/wmv/" + pr.tarih.Substring(0, 2) + pr.tarih.Substring(3, 2) + pr.tarih.Substring(6, 4) + pr.wmvFile + ".mp4";
                    tVRClips.Add(pr);
      


            }
            }

            Task t1 = Task.Factory.StartNew(() =>
            {
                CopytoAPResults(nonexist, form);
            });

            return View(tVRClips);
        }

这是我的方法。

            private ActionResult CopytoAPResults(List<long> nonexist, FormCollection form)
            {

                if (nonexist.Count()>0)
                { 
                foreach (long i in nonexist){ }
                    
                }

                return RedirectToAction("TvrPrnetExcel");
            }

1 个答案:

答案 0 :(得分:-1)

更改此内容:

   Task t1 = Task.Factory.StartNew(() =>
    {
        CopytoAPResults(nonexist, form);
    });

    return View(tVRClips);

简单来说:

        Task t1 = Task.Factory.StartNew(() =>
        {
            return CopytoAPResults(nonexist, form);
        });

As CopytoAPResults包括重定向,并且此后的重定向永远都不会达到。

相关问题