表单身份验证可以忽略 returnUrl
有没有一种简单的方法可以让表单身份验证忽略 returnURL?
因此,用户单击链接,网站超时,他们被重定向到我的登录页面(将 ReturnUrl 附加到 URL) - 我不希望发生这种情况,或者当他们再次登录时它被忽略。
Is there an easy way to get forms authentication to ignore the returnURL?
So the user clicks a link, the site timesout, they get redirected to my login page (which appends ReturnUrl to the URL) - I don't want this to happen, or for it to be ignored when they login again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果你不想展示的话,可以把它撕下来。我这样做是因为我不希望它显示我设置的 SEO 友好 URL。
在
Global.asax
文件中输入以下内容:You can strip it off if you don't want to show it. I do that because I don't want it to show with SEO-friendly URLs that I have setup.
In the
Global.asax
file put the following:一种选择是在登录表单的代码隐藏中添加一些执行以下操作的代码:
换句话说,检查登录页面是否存在 returnUrl 查询字符串参数,如果存在,则通过重定向回您自己来将其删除。
One option is to have some code in your login form's code-behind that does the following:
In other words, check in your login page for the presence of the returnUrl querystring parameter and if it's present, strip it out by redirecting back to yourself.
我认为在使用表单身份验证时,您无法阻止将其附加到 URL 上。
但是,您不需要调用
RedirectFromLoginPage
(这就是我假设你现在正在做的事情);您只需使用SetAuthCookie
保留登录状态和响应。之后重定向
任何您喜欢的地方。I don't think you can prevent this from being tacked onto the URL when using Forms Authentication.
However, you don't need to call
RedirectFromLoginPage
(which is what I'll presume you're doing at the minute); what you can do is simply useSetAuthCookie
to persist the login state andResponse.Redirect
anywhere you like after that.