没有解析json时重定向Json错误

时间:2018-01-28 14:12:23

标签: javascript asp.net redirect

我正在尝试从控制器操作重定向到另一个控制器操作。 即使调试器在第二个Controller Action中执行并且似乎在渲染它,甚至在Browser -response部分中,页面也会呈现呈现状态,其状态为200 ok我得到:

Error:SyntaxError: Unexpected token < in JSON at position 0

页面不会改变。 代码:

LocationController

 [HttpPost, ActionName("Attach")]
        public IActionResult Attach([FromBody]List<Location> locations)
        {
                Story targetStory=TempData.Get<Story>("tstory");
                if(targetStory!=null && locations!=null)
                {
                    var slocs=this.context.StoryLocations.Where(sloc=>sloc.StoryId==targetStory.Id);
                    this.context.RemoveRange(slocs);
                    this.context.SaveChanges();
                    foreach(Location loc in locations)
                    {
                        this.context.StoryLocations.Add(new StoryLocation{LocationId=loc.Id,StoryId=targetStory.Id});
                    }
                    this.context.SaveChanges();
                }

            return RedirectToAction("Index","Story");
        }

故事控制器

 [HttpGet]
        public string Test()
        {
            return test;
        }
        [HttpGet]
        public  IActionResult Index()
        {
            TempData.Clear();
            List<Story>Stories=this.context.Stories.ToList();
            return View(this.context.Stories);

        }

我试图从第二个控制器重定向到不同的操作并且发出请求并且它是正常的(状态200绿色)但它不会改变视图,即使来自&#34;故事/索引&#的铬响应34;没关系。

0 个答案:

没有答案
相关问题