Tag: 发布

将数据发布到HTTPSurl时,GetRequestStream()会抛出超时exception

我正在调用Apache服务器上托管的API来发布数据。 我正在使用HttpWebRequest在C#中执行POST。 API在服务器上具有普通HTTP和安全层(HTTPS)PORT。 当我调用HTTP URL时,它完全正常。 但是,当我调用HTTPS时,它会给我超时exception(在GetRequestStream()函数中)。 任何见解? 我正在使用VS 2010,.Net framework 3.5和C#。 这是代码块: string json_value = jsonSerializer.Serialize(data); HttpWebRequest request = (HttpWebRequest)System.Net.WebRequest.Create(“https://server-url-xxxx.com”); request.Method = “POST”; request.ProtocolVersion = System.Net.HttpVersion.Version10; request.ContentType = “application/x-www-form-urlencoded”; byte[] buffer = Encoding.ASCII.GetBytes(json_value); request.ContentLength = buffer.Length; System.IO.Stream reqStream = request.GetRequestStream(); reqStream.Write(buffer, 0, buffer.Length); reqStream.Close(); 编辑:彼得建议的控制台程序工作正常。 但是当我添加需要发布到API的数据(以JSON格式)时,它会抛出操作超时exception。 这是我添加到基于控制台的应用程序的代码,它会抛出错误。 byte[] buffer = Encoding.ASCII.GetBytes(json_value); request.ContentLength = buffer.Length;

如何使用C#发布到WordPress?

我想编写一个程序,可以使用C#通过POST方法将数据发布到WordPress中。 我不知道那样做。 我希望有人帮助我一些想法。 WordPress有任何API支持吗? 谢谢 !

为什么Sitecore会从C#API发布草稿项目,我该如何阻止它呢?

我正在使用Sitecore发布API运行我的Sitecore主数据库的预定发布。 我在一天中按计划的时间间隔调用一个Web服务,它运行以下代码(为了便于阅读,略微精简): // grab the root content node from sitecore Item contentNode = dbSource.Items[ID.Parse(“{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}”)]; PublishOptions options = new PublishOptions(sourceDatabase, targetDatabase, PublishMode.Smart, lang, DateTime.Now); options.RootItem = contentNode; options.Deep = true; Publisher p = new Publisher(options); p.PublishAsync(); 当我们运行上面的代码时,它会发布内容节点中的所有内容,包括所有后代,而不管工作流状态如何。 这就像它完全忽略了工作流程。 这不是我们所追求的,并且在我们的实时网站上造成了很多问题。 如果我们从Sitecore Desktop中运行相同的操作,它将发布内容节点中的所有内容,包括可发布的所有后代(即最终工作流阶段)。 它不会在树中发布仍处于草稿模式的任何项目。 这是必需的行为。 我已尝试通过使用以下using语句包含上述代码来将代码实现为非管理员用户: string userName = @”sitecore\******”; Sitecore.Security.Accounts.User user = Sitecore.Security.Accounts.User.FromName(userName, true); user.RuntimeSettings.IsAdministrator = false; […]

我如何将我的asp.net项目发布到我的本地iis?

我一直在寻找,我已经看到了一些方法,但我发现它们有些令人困惑。 有没有人有一个很好的教程或一步一步的写作,新手很容易遵循

使用CruiseControl.NET和MSBuild发布网站

我正在尝试设置CruiseControl.NET以自动从SVN( VisualSVN_Server )下载新版本并将其发布到beta目录。 这是关于MSBuild的CruiseControl.NET配置文件: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe C:\CI\WORKING WashMyCarHomepage\WashMyCarHomepage.csproj /noconsolelogger /p:Configuration=Debug /v:diag /p:WebProjectOutputDir=C:\inetpub\wwwroot.beta Build;Test 900 C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll CruiseControl.NET成功运行MSBuild,但MSBuild失败: standard-error stream closed — null received in event standard-output stream closed — null received in event process exited event received 我还试图从控制台手动运行MSBuild,以尝试它是否单独工作。 但我无法获得正确的输出(可在网上发布)。 我试过了: C:\Windows\Microsoft.NET\Framework\v4.0.30319>MSBuild.exe C:\CI\WORKING\WashMyCarHomepage\WashMyCarHomepage.csproj /property:OutDir=C:/CI/TEST;Configuration=Release /t:Publish 但该项目被“跳过不可发布的项目”所忽略。 我有一个以下解决方案的结构: WashMyCarHomepage\WashMyCarHomepage.sln WashMyCarHomepage\Repository\Repository.csproj WashMyCarHomepage\WashMyCarHomepage\WashMyCarHomepage.csproj 我该如何解决这个问题?

使用HttpWebRequest在POST中使用C#Escape Plus Sign(+)

我在发送POST数据时遇到问题,包括密码字段中的“+”字符, string postData = String.Format(“username={0}&password={1}”, “anyname”, “+13Gt2”); 我正在使用HttpWebRequest和webbrowser来查看结果,当我尝试使用HttpWebRequest从我的C#WinForms 登录到POST数据到网站时,它告诉我密码不正确。 (在源代码[richTexbox1]和webBrowser1中)。 尝试使用我的另一个帐户,它不包含’+’字符,它允许我正确登录(使用字节数组并将其写入流) byte[] byteArray = Encoding.ASCII.GetBytes(postData); //get the data request.Method = “POST”; request.Accept = “text/html”; request.ContentType = “application/x-www-form-urlencoded”; request.ContentLength = byteArray.Length; Stream newStream = request.GetRequestStream(); //open connection newStream.Write(byteArray, 0, byteArray.Length); // Send the data. newStream.Close(); //this works well if user does not includes symbols 从这个问题我发现HttpUtility.UrlEncode()是逃避非法字符的解决方案,但我无法找到如何正确使用它,我的问题是,在使用urlEncode()对我的POST数据进行url编码之后我该怎么办?正确地将数据发送给我的请求 ? […]

C# – Json POST请求已发送但未被PH​​P服务器接收

我正在从C#windowsform应用程序向OpenShift(Redhat)上托管的PHP服务器发送HTTP请求。 我使用POST方法,使用Json数据。 问题是: 数据似乎被正确发送(我看到wireshark中的数据包) php脚本正确启动,我在日志中看到收到了一条POST消息 但没有收到任何POST数据.. 这是C#代码 : string json = “{\”user\”:\”test\”,” + “\”n\”:\”2\”}”; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(“http://……..rhcloud.com/webservices.php”); request.Method = “POST”; request.ContentType = “application/json”; request.ContentLength = json.Length; using (var streamWriter = new StreamWriter(request.GetRequestStream())) { streamWriter.Write(json); streamWriter.Close(); var httpResponse = (HttpWebResponse)request.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var result = streamReader.ReadToEnd(); Debug.WriteLine(“R : ” + […]

通用处理程序参数大小限制?

我有一些JavaScript代码生成一个非常长的脚本,然后将其发送回服务器,以创建一个csv的通用处理程序。 我发送数据的JavaScript代码是: function postwith(to, p) { var myForm = document.createElement(“form”); myForm.method = “post”; myForm.action = to; for (var k in p) { var myInput = document.createElement(“input”); myInput.setAttribute(“name”, k); myInput.setAttribute(“value”, p[k]); console.log(k+”:”+p[k]); myForm.appendChild(myInput); } document.body.appendChild(myForm); myForm.submit(); document.body.removeChild(myForm); } 在我的控制台中,我可以看到整个字符串被添加到表单中(“console.log(k +’:’+ p [k]);”所以客户端似乎工作正常。 在我检查请求/响应的网络视图中,我可以看到“内容”(表单数据属性的名称)不完整 – 它在中间被剪切。 服务器端非常简单 – 将内容作为csv发回: public class Excel : IHttpHandler { public void […]

从HttpListener解析POST参数

假设我有HttpListener。 它听一些端口和IP。 当我发送POST请求时它会抓住它。 我如何从HttpListenerRequest解析POST参数? HttpListenerContext context = listener.GetContext(); HttpListenerRequest request = context.Request; if ( request.HttpMethod == “POST” ) { // Here i can read all parameters in string but how to parse each one i don’t know }

HttpWebRequest响应产生HTTP 422.为什么?

我正在尝试以编程方式向Web服务器发送POST请求,以便登录然后执行其他需要登录的请求。 这是我的代码: byte[] data = Encoding.UTF8.GetBytes( String.Format( “login={0}&password={1}&authenticity_token={2}” +”&login_submit=Entra&remember_me=1″, HttpUtility.UrlEncode(username), HttpUtility.UrlEncode(password), HttpUtility.UrlEncode(token))); //Create HTTP-request for login HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(“http://www.xxx.xx/xx/xx”); request.Method = “POST”; request.ContentType = “application/x-www-form-urlencoded”; request.ContentLength = data.Length; request.CookieContainer = new CookieContainer(); request.Accept = “application/xml,application/xhtml+xml,text/html; +”q=0.9,text/plain ;q=0.8,image/png,*/*;q=0.5”; request.Referer = “http://www.garzantilinguistica.it/it/session”; request.Headers.Add(“Accept-Language”, “de-DE”); request.Headers.Add(“Origin”, “http://www.xxx.xx”); request.UserAgent = “C#”; request.Headers.Add(“Accept-Encoding”, “gzip, deflate”); 发送请求后 //Send post request […]