gpt4 book ai didi

c# - MVC 5 - RedirectToAction 不重定向

转载 作者:太空狗 更新时间:2023-10-29 17:28:42 26 4
gpt4 key购买 nike

您好,我的 RedirectToAction 没有重定向有问题。我的代码成功命中了重定向上的断点,因此我可以确认它正在被调用。然而似乎什么也没发生。

我已经尝试查看 Chrome 中的网络流量,但似乎没有任何明显的迹象。我一定是漏掉了一些简单的东西!

    //
// 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);
}

最佳答案

尝试

return RedirectToAction("Index", "Blog");

关于c# - MVC 5 - RedirectToAction 不重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20491271/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com