【发布时间】:2019-04-28 14:46:26
【问题描述】:
我在从 Api Controller 重定向到 Controller 时遇到了一些麻烦。我可以在邮递员的回复中看到,返回了正确的视图。
public class ApiController : Controller
{
[HttpPost("/someApiAction/{id}")]
public async Task<IActionResult> SomeApiAction(string id)
{
return RedirectToAction("Action", "Other", new { id = id});
}
}
其他控制器:
public class OtherController : Controller
{
public async Task<IActionResult> Action(string id)
{
var model = new Model();
return View(model);
}
}
代码到达 return View(model) 但它没有显示。
有人可以帮忙吗?
【问题讨论】:
-
重定向中的控制器名称应该是
Other,而不是Controller。 -
已更正。无论如何,事实并非如此。
-
@Xardas 正确的观点是指源内容(即 html)或显示的 URL?
-
显示的代码也准确吗?您有没有等待的异步操作。
-
我们需要查看更多信息才能真正提供帮助。你真的对“Views/Other/Action.cshtml”有看法吗?
标签: c# .net asp.net-web-api model-view-controller asp.net-core