目前,我只是使用客户端Javascript(location.href
),但我想知道在Asp.Net中是否有办法找出用户最初输入的URL(假设我自己没有更改它)通过301),或至少以简单可靠的方式跟踪它。由于我通过global.asax(例如Context.RewritePath
)使用我自己的URL重写实现,这不是一件容易的事,特别是因为我不想触及太多。
实施例
Global.asax:
public override void Init()
{
base.Init();
this.BeginRequest += new EventHandler(Global_BeginRequest);
}
void Global_BeginRequest(object sender, EventArgs e)
{
if (VARIOUSCONDITIONS) Context.RewritePath("SOMEURL");
}
SomePage.aspx.cs
protected void Page_Init(object sender, EventArgs e)
{
//Request.RawUrl is equal to "SOMEURL", as
//are other properties that store the URL.
}
答案 0 :(得分:1)
也许我误解了你的问题,但是如果你试图捕获用户首次点击你网站的页面,你不能在global.asax的session_start事件中捕获它吗?然后存储在sessionstate或数据库中以备将来使用?