WTM icon indicating copy to clipboard operation
WTM copied to clipboard

未登陆状态跳转到登陆页返回还是200

Open liuliang-wt opened this issue 6 years ago • 1 comments

@alienwow 群里有人反应没有登陆的时候返回的还是200,而不是302,前端需要判断的时候无法判断。你检查一下

liuliang-wt avatar Dec 09 '19 10:12 liuliang-wt

我们是这样处理的,因为项目比较小。API和Website放到一起了。 在Login里增加如下代码,当未登录时让其返回401,当然也可以自定义其他的。 var apiRefer = HttpContext.Request.Query["ReturnUrl"]; if (!string.IsNullOrWhiteSpace(apiRefer) && apiRefer.ToString().StartsWith("/api/")) { HttpContext.Response.Clear(); HttpContext.Response.StatusCode = 401; return new EmptyResult(); }

harvey0720 avatar Dec 16 '19 08:12 harvey0720