简体   繁体   English

使用C#将infopath表单下载为XML文件

[英]Download infopath form as XML file using C#

I am tryign to download the InfoPath form on one of my intranet sites, say _http://ABC/XYZ/abc/PhysicsDept/Requests/Myform.xml (this is the value of variable formName ) using C#. 我尝试使用C#在我的一个Intranet网站上下载InfoPath表单,例如_http://ABC/XYZ/abc/PhysicsDept/Requests/Myform.xml(这是变量formName的值)。 I am using the below code 我正在使用以下代码

using (WebClient client = new WebClient())
{
    // Set the credentials to be used for download from Sharepoint
    client.Credentials = CredentialCache.DefaultCredentials;
    client.DownloadFile(formName, "tempForm.xml");
} 

tempForm.xml is created, but sadly it contains some weird html data which is surely what i dont want. tempForm.xml已创建,但可悲的是它包含一些奇怪的html数据,这些数据肯定是我所不想要的。 If i simply try to open the link, the value taken from formName, then i am able to easily view it as an XML, so the link is correct and working. 如果我只是尝试打开链接,该值取自formName,那么我能够轻松地将其视为XML,因此链接是正确且有效的。

Can anyone please help me on this one? 谁能帮我这个忙吗?

Most likly you endup with HTML rendering of the form (XML) because corresponding form template was browser enabled. 最有可能的是,您最终获得了表单(XML)的HTML呈现,因为相应的表单模板已启用浏览器。

Add "?NoRedirect=true" query parameter (See Query Parameters for Browser-Enabled forms ) to force file download. 添加“?NoRedirect = true”查询参数(请参阅启用浏览器的表单的查询参数 )以强制下载文件。 (There should be some other way too which I can't remember right now...) (也应该有其他方式我现在不记得了...)

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

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