题
我想从我的管理模块执行在C#的帧重定向为IIS 7。
结果当我打电话context.Response.Redirect(@"http://www.myRedirect.org");
the正确显示的页面,而且在浏览器中显示的地址。而这正是我不想要什么。
点击所以,我想是这样的:
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在做什么意外都没有工作。
解决方案
要需要发送回所包含的HTML码的执行帧重定向与单个帧FRAMESET,与它的源设置为 http://www.myRedirect.org 。至于服务器和浏览器而言没有重定向已经发生 - 它只是得到了一些HTML代码
执行Response.Redirect
会,因为你已经发现,导致浏览器做出新的一页新的新的请求,显示用户在标题栏的新地址。它通常用于当一个页面实际上改变其地址,但业主仍然希望它从原来的URL可达也。
修改强>:HTML帧重定向样品: HTTP:// EN .wikipedia.org /维基/ URL_redirection#Frame_redirects
不隶属于 StackOverflow