简体   繁体   English

将 XML 数据发布到 aspx 页面并从后面的代码重新编辑到页面

[英]Post XML Data to aspx page and reditect to the page from code behind

I need to post some xml data to a different aspx page and redirect to the same page.我需要将一些 xml 数据发布到不同的 aspx 页面并重定向到同一页面。 I tried the following code it does post to the page sucessfully but i need to redirect to the same page with posted data我尝试了以下代码,它成功发布到页面,但我需要重定向到发布数据的同一页面

         req.Method = "POST";       
        req.ContentType = "text/xml";     
        StreamWriter writer = new StreamWriter(req.GetRequestStream());
        writer.WriteLine(doc.InnerXml);
        writer.Close();
        rsp = req.GetResponse();

could you guys help me with this?你们能帮我解决这个问题吗?

Thank in advance!!!预先感谢!!!

Response.Redirect should work: Response.Redirect应该工作:

rsp.Redirect(url);

What you're asking for is impossible in it's current form, this is due to the way HTTP works.您所要求的以目前的形式是不可能的,这是由于 HTTP 的工作方式。

When you use POST you simply send data to the server, and collect the result.当您使用 POST 时,您只需将数据发送到服务器并收集结果。 If you then want to show the user that page, you'll have to make a new request by the way of GET.如果您想向用户显示该页面,则必须通过 GET 方式发出新请求。

The easiest way to do this in asp.net is using Response.Redirect() .在 asp.net 中执行此操作的最简单方法是使用Response.Redirect()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM