将请求的 URL 存储在 Global.asax 中,而不在 ASP.NET 中存储会话状态
我有一个复杂的 URL 重写方案,它破坏了内置的 Forms Authentication ReturnUrl 机制。我想获取请求的 URL,以便稍后从我的 login.aspx 重定向。我可以通过 HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath 在 Application_BeginRequest 中获取此 URL。但是,Session 状态在 Application_BeginRequest 中不可用。在 ASP.NET 将我重定向到 login.aspx 之前,如何存储此 URL?
I have a complex URL rewriting scheme which breaks the built in Forms Authentication ReturnUrl mechanism. I would like to grab the requested URL for later redirection away from my login.aspx. I can get this URL in Application_BeginRequest via HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath. However, Session state is not available in Application_BeginRequest. How can I store this URL prior to ASP.NET redirecting me to login.aspx?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
客户端 cookie 是一种选择吗?如果没有可用的会话状态,我不相信您有任何服务器端选择。
Are client cookies an option? Without an available session state, I don't believe you have any server-side choices.
您可以使用静态。但是,您需要一些信息来为每个用户提供密钥(例如用户名、会话标识符等)。如果您必须在用户登录之前执行此操作,那么您唯一的选择是将某种标识符填充到 cookie 中,此时您可能只想将整个 URL 放在那里。
You could use a static. However, you'll need something to key it to each user (e.g. user name, session identifier etc.). If you have to do it before the user is logged on, your only option is to stuff some sort of identifier into a cookie at which point you might just want to put the whole URL there.