在ASP.NET中获取Referer的网页网址 [英] Get URL of Referer page in ASP.NET

查看:243
本文介绍了在ASP.NET中获取Referer的网页网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个ASP.NET项目,目前在东西击中。
基本上,我有三个不同层次的用户
1.管理员
2. DMV
3.来电

I am working on an ASP.NET project and currently struck in something. Basically, I have three different levels of users 1. Admin 2. DMV 3. Caller

所有用户有其各自的目录,并根据他们的权利中的那些可访问的资源。当有人要登录到应用程序,他必须使用相同的login.aspx页面是在根目录present,一旦登录后,他被重定向到他的各文件夹的首页,根据他的特权。

All the users have their respective directories, and can access the resources in those according to their rights. When someone wants to sign-in to the application, he has to use the same login.aspx page that is present in the root directory, and once logged-in, he is redirected to the home page of his respective folder, based on his privilege.

在我的应用程序,有时当会话不情愿地关闭,用户将被重定向到登录页面,或者他知道页面的完整URL,只想赶快登录并使用REDIRECT_URL进入该页面变量传递作为查询字符串,他不能这样做。在这里,当他在他记录将被重定向到他的主页,这将让他再次这样做了一些行动以达到他的页面。

In my application, sometimes when a session closes unwillingly, the user is redirected to the login page, or he knows the complete url of the page and just want to quickly login and get to that page using a "Redirect_URL" variable passed as a query string, he can't do that. Here when he has logged in he is redirected to his home page, that will make him again do a number of actions to reach the page he was on.

所以,我需要的login.aspx页面,检查引用页的URL,将其存储在查询字符串说REDIRECT_URL使用类似HTTP_REFERER,一旦用户成功登录,他将被重定向到页,present在REDIRECT_URL变量。

So, I need the login.aspx page to check the URL of referrer page, store it in a query string say "Redirect_url" using something like HTTP_REFERER, and once the user has successfully logged in, he is redirected to the page, present in the "Redirect_url" variable.

我也找过的地方给予的Global.asax解决方案但对我来说,我认为上述逻辑将是最好的。

I have also looked for the Global.asax solution given somewhere but in my case, I think the above mentioned logic will work best.

推荐答案

两件事情:

第一:一个快速的解决方案,只需使用 Request.ServerVariables [HTTP_REFERER] Request.UrlReferrer 获得HTTP网址标头值。

First: for a quick solution, just use Request.ServerVariables["HTTP_REFERER"] or Request.UrlReferrer to get the HTTP Referrer header value.

二:使用ASP.NET内置的Forms身份验证类,它们可以执行重定向(和查询字符串重定向到)管理一切为您

Second: Use ASP.NET's built-in Forms authentication classes, they can perform the redirection (and querystring redirect-to) management all for you.

这篇关于在ASP.NET中获取Referer的网页网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆