我有一个带有 post 操作的登录控制器,它在成功登录后重定向到主页。我正在使用以下代码进行重定向,它在 Chrome 和 Firefox 中运行良好。但不会在 IE 和 EDGE 中重定向,并且未设置响应 cookie
private ActionResult RedirectToLocal(string returnUrl)
{
if (Url.IsLocalUrl(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToRoute("default", new { controller = "", action = "" });
}
}
Run Code Online (Sandbox Code Playgroud)
我的登录操作
public IActionResult Login(string userName, string password)
{
try
{
if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
throw new InvalidOperationException("Username/Password can not be empty");
var session = CreateSession(userName, password);
var returnUrl = Request.Query["returnUrl"];
return RedirectToLocal(returnUrl);
}
catch (Exception ex)
{
ModelState.AddModelError("Login", ex.Message);
}
return View(); …Run Code Online (Sandbox Code Playgroud) 使用define preprocessor指令为什么以下程序输出4而不是3?
#include <stdio.h>
#define MAX(A,B)((A)>(B)) ? A : B
int max_t(int a, int b)
{
return ((a)>(b)) ? a : b;
}
int main()
{
int i=1;
int j=2;
int val = MAX(++i, ++j); // this outputs 4 but why?
//int val = max_t(++i, ++j);
printf("%d\n", val);
return 0;
}
Run Code Online (Sandbox Code Playgroud)