【发布时间】:2020-02-07 23:35:42
【问题描述】:
对于 .net core RazorPages,通常将代码放在 OnGet() 或 OnPost() 函数中执行某些工作,然后将用户重定向到另一个带有一些数据(例如匿名对象)的 RazorPage:
public async Task<IActionResult> OnPost()
{
// do some work
// redirect the user to another page
return RedirectToPage("NextPage", new { user = _user, isComplete = _isComplete });
}
问题是 RedirectToPage 总是 将对象中的参数作为 GET 重定向,参数在浏览器地址栏中可见:
https://example.com/NextPage?user=Pete&isComplete=true
如何强制 RazorPage 将重定向请求作为 POST 而不是 get 发送?
【问题讨论】: