English 中文(简体)
我正试图将数据张贴到一个星子上。 该员额使用HTTPRequest和HTTPResponse进行。
原标题:I am trying to Post Data to an Iframe in asp.net. The post is performed using HTTPRequest and HTTPResponse

在允许用户向多个供应商签字时,我试图执行单一签字。 每个供应商必须证明,必须作为形式员额发送。 我将这一举动说成是“HTTPR”问题,并将反应重新纳入以下法典。

private static string PostDataToServerAndGetResponse()
{
Uri uri = new Uri("http://www.amazon.com/exec/obidos/search-handle-form/102-5194535-6807312");
string data = "field-keywords=ASP.NET 2.0";
        if (uri.Scheme == Uri.UriSchemeHttp)
        {

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
            request.Method = WebRequestMethods.Http.Post;
            request.ContentLength = data.Length;
            request.ContentType = "application/x-www-form-urlencoded";
            StreamWriter writer = new StreamWriter(request.GetRequestStream());
            writer.Write(data);
            writer.Close();
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());
            string tmp = reader.ReadToEnd();
            response.Close();
            //return response.ResponseUri.AbsoluteUri;
            return tmp;

        }

        return null;
}

退还价值——奖状是一种超声波,我想显示为一机。 我可以这样做,在地块上增加利器控制,并将案文财产确定为上述功能所返还的价值。

<iframe  id="myIFrame" runat="server"  height="700" width="950"  frameborder="0" />
    <asp:Literal ID="litFrame" runat="server" Mode="PassThrough" />

 </iframe>

 litFrame.Text = SAML.PostDataToServerAndGetResponse();

The above code dispaly the page fine, but when i click on any of the links it opens a new page.
There is no apparent framebusting java script, because if I set the src attribute of the iframe to response.ResponseUri.AbsoluteUri, all the clicks and page refreshes stay in the frame.

What I want to achieve

Display the Result of the post into Iframe and all the user to perform any clicks. Condition: Clicks in the frame should refresh the frame and not jump out to a new page.

最佳回答

字眼不行。 <代码><iframe> tag的内涵只有在标不为浏览器所支持的情况下才能显示,而不是作为单体的缺省内容。 我感到惊讶的是,你在网页上看到了字面上的任何内容——实际上有<条码>和>;iframe>输出在您的html来源中,或者有伙伴关系。 互联网的智能和产出有所不同?

你们的选择是:

  • Set the url of the iframe to a page/handler/etc that will generate the content you want inside the iframe (ie, THAT page calls your PostDataToServerAndGetResponse method)
  • Use javascript to write the content into the iframe
  • You could set the target of a <form> to the iframe, and post the data to it

I d say option 1 would be the easiest/cleanest.

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签