简体   繁体   English

实现客户端ajax登录,使用ajax注销是否安全还是需要刷新?

[英]Implementing client-side ajax login, is it safe to logout using ajax or do I need to refresh?

I'm building a client-side ajax login for Asp.Net MVC by doing jquery posts to the controller to log in the user. 我通过对控制器进行jquery发布以登录用户来为Asp.Net MVC构建客户端ajax登录。

What I'm wondering is when the user goes to log out, should the page refresh? 我想知道的是,当用户注销时,页面应该刷新吗? (for security reasons) (出于安全原因)

This tutorial here says: 本教程在这里说:

There will always be a page refresh on logout. 注销时始终会刷新页面。 This is necessary to ensure that any user-specific information is cleared from the page. 这是确保从页面中清除所有特定于用户的信息所必需的。

And I figured since it's tutorial on doing client-side ajax login's that there must be a reason why they did it that way. 而且我认为,因为这是有关进行客户端Ajax登录的教程,所以一定有他们这样做的原因。 If I do an ajax logout, is it safe to just switch everything to an anonymous view without reloading the page? 如果我执行ajax注销,仅将所有内容切换到匿名视图而不重新加载页面是否安全?

You don't need to refresh, Ajax is a simple HTTP request, so if the request properly logs you out on the server, you just need to make sure there's no relevant data left on the client, for example in a JavaScript object or in a cookie. 您无需刷新,Ajax是一个简单的HTTP请求,因此,如果该请求正确地将您注销到服务器上,则只需要确保客户端上没有剩余相关数据即可,例如JavaScript对象或一块饼干。

In any case you can still clean everything up without a page refresh. 无论如何,您仍然可以清理所有内容而无需刷新页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM