我想从我的 IIS 7 托管模块在 C# 中执行帧重定向。
当我调用时context.Response.Redirect(@"http://www.myRedirect.org");
,会显示正确的页面,但地址也会显示在浏览器中。这正是我不想要的。
所以我想要类似的东西:
private void OnBeginRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;
HttpContext context = app.Context;
// make a frame redirect if a specified page is called
if (context.Request.ServerVariable["HTTP_REFERER"].Equals(@"http://www.myPage.org/1.html"))
{
// perform the frame redirect here, but how?
// so something like
context.Response.Redirect(@"http://www.myRedirect.org");
// but as I said that doesn't redirect as I want it to be
}
}
有什么想法吗?
编辑:
我尝试了这个例子,所以我有:
private void OnBeginRequest(object sender, EventArgs e)
{
HttpApplication app = (HttpApplication)sender;
HttpContext context = app.Context;
// make a frame redirect if a specified page is called
if (context.Request.ServerVariable["HTTP_REFERER"].Equals(@"http://www.myPage.org/1.html"))
{
// perform the frame redirect here, but how?
context.Response.Write(@"<html>");
context.Response.Write(@"<head>");
context.Response.Write(@"</head>");
context.Response.Write(@"<frameset rows=""100%,*"" framespacing=""0"" frameborder=""NO"" border=""0"">");
context.Response.Write(@"<frame src=""http://www.myRedirect.org"" scrolling=""auto"">");
context.Response.Write(@"</frameset>");
context.Response.Write(@"<noframes>");
context.Response.Write(@"<body>Some text...");
context.Response.Write(@"</body>");
context.Response.Write(@"</noframes>");
context.Response.Write(@"</html>");
}
}
但这也没有正确重定向。我的浏览器中仍然显示重定向地址。那么还有什么想法吗?
编辑:我显然犯了一个错误。上面的代码可以工作并且可以满足我的要求。它首先不起作用,因为我的重定向 url 做了一些意想不到的事情。