ASP.NET - Response.Redirect的填充不介绍人网址 [英] ASP.NET - Response.Redirect Not Populating Url Referrer

查看:142
本文介绍了ASP.NET - Response.Redirect的填充不介绍人网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得我做这个一吨的时候,但我不能为我的生活出了什么错误。

I feel like i've done this a ton of times, but i can't for the life of me figure out what is going wrong.

Default.aspx的:

protected void Page_Load(object sender, EventArgs e)
{
   var r1 = Request.UrlReferrer; // null
   var r2 = Request.ServerVariables["HTTP_REFERRER"]; // null
}

SingleSignOn.aspx:

protected void Page_Load(object sender, EventArgs e)
{
   Response.Redirect("/");
}

如果我在网址栏中输入/SingleSignOn.aspx,它重定向到Default.aspx的,但引用为null。

If i type "/SingleSignOn.aspx" in the URL, it redirects to Default.aspx, but the referrer is null.

我缺少的是在这里吗?

什么我尝试做(这是一个简单的例子),是任何页面上,我会有一些JavaScript来做到以下几点:

What im trying to do (this is a simplified example), is on any page, i will have some JavaScript to do the following:

window.location.replace('~/SingleSignOn.aspx');

其中,你猜对了,签署的用户,并重定向到首页。

Which, you guessed it, signs the user in, and redirects to the homepage.

但我需要建立逻辑成JavaScript来不是重定向到SingleSignOn.aspx页面如果我们只是从那里来的。

But i need to build logic into that JavaScript to not redirect to the SingleSignOn.aspx page if we just came from there.

是否引用只能由实际的链接用户点击获取填充?

Does the referrer only get populated by actual link user clicks?

我怎样才能做到这一点呢?我不希望使用查询字符串,因为我不希望看到在URL中。

How can i do this then? I don't want to use QueryString because i dont want to see that in the URL.

唯一的其他选择,我能想到的是会话。

The only other option i can think of is Session.

请帮忙。 =(

推荐答案

所以,我做了一些Google'ing找到我的答案。

So, i've done some Google'ing to find my answer.

没有感谢堆栈溢出 - 开玩笑,=)

No thanks to Stack Overflow - kidding, =)

所以,URL引荐仅由一个实际的客户点击(锚标记,按钮)填充。

So the URL Referrer is only populated by an actual client-click (anchor tag, button).

而不是当你手动把它的URL(这是我的JavaScript是做)。

Not when you manually put it in the URL (which is what my JavaScript is doing).

解决方案我这样做有同是创建SingleSignOn.aspx页面上的cookie,并从JavaScript的读取cookie之前,我再次重定向。

The solution i am doing to have to with is to create a cookie on the SingleSignOn.aspx page, and read that cookie from the JavaScript before i redirect again.

正是我需要的,更多的饼干。 =(

Just what i need, more cookies. =(

除非有人在这里有一个更好的主意,那是什么病用下去。

Unless someone here has a better idea, that's what ill be going with.

这篇关于ASP.NET - Response.Redirect的填充不介绍人网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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