本文介绍了MVC 5 - RedirectToAction不重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我有一个问题,我不RedirectToAction重定向。我的code成功击中置于重定向,所以我可以确认它是被称为一个断点。似乎没有任何不过的事情发生。
我试图寻找在Chrome网络流量,似乎没有被任何明显。我一定是简单的东西!
//
// POST:/博客/ CreateBlog
[HttpPost]
[ValidateAntiForgeryToken]
公众的ActionResult CreateBlog(BlogViewModel模型)
{
变种用户id = User.Identity.GetUserId();
model.UserId =用户id; 如果(ModelState.IsValid&安培;&安培;!model.UserId = NULL)
{
Mapper.CreateMap< BlogViewModel,博客>();
如果(_blogProcess.CreateBlog(Mapper.Map< BlogViewModel,博客>(模型)))
{
RedirectToAction(索引,博客);
}
} //如果我们走到这一步,事情失败了,重新显示形式
返回查看(模型);
}
解决方案
尝试
返回RedirectToAction(指数,博客);
Hi I have a problem with my RedirectToAction not redirecting. My code successfully hits a breakpoint placed on the Redirect so I can confirm it is being called. Nothing seems to happen however.
I have tried looking at the network traffic in Chrome and there doesn't seem to be anything obvious. I must be missing something simple!
//
// POST: /Blog/CreateBlog
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult CreateBlog(BlogViewModel model)
{
var userId = User.Identity.GetUserId();
model.UserId = userId;
if (ModelState.IsValid && model.UserId != null)
{
Mapper.CreateMap<BlogViewModel, Blog>();
if (_blogProcess.CreateBlog(Mapper.Map<BlogViewModel, Blog>(model)))
{
RedirectToAction("Index", "Blog");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
解决方案
try
return RedirectToAction("Index", "Blog");
这篇关于MVC 5 - RedirectToAction不重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!