C# C语言中的帧重定向#

C# C语言中的帧重定向#,c#,iis-7,httpcontext,ihttpmodule,C#,Iis 7,Httpcontext,Ihttpmodule,我想从IIS 7的托管模块中以C#格式执行帧重定向。 当我调用context.Response.Redirect(@)时http://www.myRedirect.org");将显示正确的页面,但也会在浏览器中显示地址。这正是我不想要的。 所以我想要这样的东西: private void OnBeginRequest(object sender, EventArgs e) { HttpApplication app = (HttpApplication)sender; HttpC

我想从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>");
    }
}
private void OnBeginRequest(对象发送方,事件参数e)
{
HttpApplication应用程序=(HttpApplication)发送方;
HttpContext=app.context;
//如果调用指定页,则进行帧重定向
if(context.Request.ServerVariable[“HTTP_REFERER”].Equals(@)http://www.myPage.org/1.html"))
{
//在这里执行帧重定向,但如何执行?
context.Response.Write(@“”);
context.Response.Write(@“”);
context.Response.Write(@“”);
context.Response.Write(@“”);
context.Response.Write(@“”);
context.Response.Write(@“”);
context.Response.Write(@“”);
context.Response.Write(@“一些文本…”);
context.Response.Write(@“”);
context.Response.Write(@“”);
context.Response.Write(@“”);
}
}
但这也不能正确地重定向。我的浏览器中仍显示重定向地址。还有其他想法吗?

编辑: 我显然犯了一个错误。上面的代码可以工作,并且做我想要的事情。它首先无法工作,因为我的重定向url执行了一些意外操作。

要执行重定向,您需要发回包含单个帧的框架集的HTML代码,其源代码设置为。就服务器和浏览器而言,没有发生重定向,只是收到了一些HTML代码

正如您所观察到的,执行
响应。重定向将导致浏览器向新页面发出新请求,并在标题栏中向用户显示新地址。它通常用于页面实际更改其地址,但所有者仍然希望可以从原始URL访问它


编辑:HTML框架重定向示例:

维基百科文章(链接在我文章中的“框架重定向”一词上)中有一个很好的例子可以发送HTML代码,但我从来没有编写过服务器模块,所以我不知道你会怎么做。可能需要
响应。是否编写(…HTML代码…