【发布时间】:2012-08-25 02:32:39
【问题描述】:
我的CommentsController 中有以下几种方法。
[HttpGet]
[Authorize]
public ActionResult New(long id)
{
return RedirectToAction("Details", "Posts", new { id }); // lets be graceful.
}
[HttpPost]
[Authorize]
public ActionResult New(long id, string comment, IMiniPrincipal principal)
{
throw new NotImplementedException();
}
两者都通过任何posts/{id}/comment 路由解决,其中 id 是一个数值。我添加了GET 操作主要是为了避免混淆(当他们尝试手动访问路由而不是通过POST 表单时,我不只是告诉用户它不存在,而是将他们重定向到评论会的帖子'已提交)。
问题是我是否可以在 HTTP GET 请求中使用永久重定向结果,但在 HTTP POST 请求期间仍然不能永久重定向?
【问题讨论】:
标签: c# asp.net-mvc-3 redirect routing