Tag: asp.net

如何在iPhone中使用C#.net for Push Notifcation来准备后端

using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net; using System.IO; using System.Text; using System.Security.Authentication; using System.Net.Security; using System.Net.Sockets; using System.Security.Cryptography.X509Certificates; using Newtonsoft.Json.Linq; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnPush_Click(object sender, EventArgs e) { pushMessage(txtDeviceID.Text.Trim(), txtPayload.Text.Trim()); } public […]

发送推送通知从Iphone从asp.net C#

` public void pushMessage(string deviceID) { int port = 30; String hostname = "gateway.sandbox.push.apple.com"; String certificatePath = HttpContext.Current.Server.MapPath("PushKey.p12"); X509Certificate2 clientCertificate = new X509Certificate2(System.IO.File.ReadAllBytes(certificatePath), "mypassword"); X509Certificate2Collection certificatesCollection = new X509Certificate2Collection(clientCertificate); TcpClient client = new TcpClient(hostname, port); SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null); try { sslStream.AuthenticateAsClient(hostname, certificatesCollection, SslProtocols.Ssl3, false); MemoryStream memoryStream = new MemoryStream(); […]

SignalR .Net客户端失败,设备上出现500个服务器错误,在模拟器上正常工作

我试图在我的应用程序中实现聊天,在后端使用azure asp.net web api,在前端使用xamarin ios。 所以在后端我用这几行configuration我的集线器: var hubConfiguration = new HubConfiguration(); hubConfiguration.EnableDetailedErrors = true; app.MapSignalR("/signalr", hubConfiguration); 这是我的中心来源: [HubName("Chat")] public class Chat : Hub { public Task JoinRoom(string roomName) { return Groups.Add(Context.ConnectionId, roomName); } public Task LeaveRoom(string roomName) { return Groups.Remove(Context.ConnectionId, roomName); } public Task Send(string message, string room) { return Clients.OthersInGroup(room).addMessage(message); } } 在Xamarin ios客户端上,一切都非常简单: […]

从IOS发送图像到asp.net web服务

在我的IOS应用程序中,我需要将图像发送到ASP.NET Web服务。 我想以字节forms的图像,然后将其转换回服务器端的图像forms。 现在我正在使用这些行将图像转换为IOS中的字节: NSData *imageData=UIImagePNGRepresentation([Mybutton currentBackgroundImage]); 这一行给出了734775字节的字节,这太多了,所以不能发送肥皂请求。 那么,现在我怎么才能达到这个目标呢? 当调用服务的us soap请求时,它给了我这个错误: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body><soap:Fault> <faultcode>soap:Server</faultcode> <faultstring> System.Web.Services.Protocols.SoapException: There was an exception running the extensions specified in the config file. —&gt; System.Web.HttpException: Maximum request length exceeded. at System.Web.HttpRequest.GetEntireRawContent() at System.Web.HttpRequest.get_InputStream() at System.Web.Services.Protocols.SoapServerProtocol.Initialize() — End of inner exception stack trace — at […]

ASP.NET Webforms不会呈现Chrome / iOS的回传JavaScript函数

Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X; en-us) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/21.0.1180.80 Mobile/9A405 Safari/7534.48.3至Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X; en-us) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/21.0.1180.80 Mobile/9A405 Safari/7534.48.3我们的.NET 4 webforms应用程序,定义__doPostBack函数的脚本不存在于页面上,因此没有使用它的工作。 如果我们提供任何其他用户代理string(比如说Safari),它就可以正常工作。 有人可以解释这个吗?

WebAPI无法parsing多部分/表单数据文章

我试图接受来自客户端(iOS应用程序)的文章,我的代码在阅读stream时一直失败。 说消息不完整。 我一直试图让这个工作几个小时,似乎是我的消息格式或东西是错误的。 所有我想要做的是读取一个string,但我正在与谁在做iOS部分的开发人员只知道如何发送multipart / form-data而不是content-type json。 这是确切的错误: 意外的MIME多部分stream结束。 MIME多部分邮件不完整。“ 它在这里失败: await Request.Content.ReadAsMultipartAsync(provider); 头: POST http://localhost:8603/api/login HTTP/1.1 Host: localhost:8603 Accept-Encoding: gzip,deflate Content-Type: multipart/form-data; boundary=————nx-oauth216807 Content-Length: 364 Accept-Language: en-us Accept: */* Connection: keep-alive 身体: ————–nx-oauth216807 Content-Disposition: form-data; name="token" CAAH5su8bZC1IBAC3Qk4aztKzisZCd2Muc3no4BqVUycnZAFSKuleRU7V9uZCbc8DZCedYQTIFKwJbVZCANJCs4ZCZA654PgA22Nei9KiIMLsGbZBaNQugouuLNafNqIOTs9wDvD61ZA6WSTd73AVtFp9tQ1PmFGz601apUGHSimYZCjLfGBo40EBQ5z6eSMNiFeSylym1pK4PCvI17fXCmOcRix4cs96EBl8ZA1opGKVuWizOsS0WZCMiVGvT ————–nx-oauth216807– 这是WebAPI代码: public async Task<HttpResponseMessage> PostFormData() { // Check if the request contains multipart/form-data. if (!Request.Content.IsMimeMultipartContent()) { […]