0
I 포트에 요청 60,080HttpListenerContext.Request.InputStream 항상 null
var XHR = new XMLHttpRequest();
XHR.open('GET', 'http://localhost:60080/api/products');
XHR.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
XHR.body = JSON.stringify({ email: "[email protected]", response: { name: "Tester" } });
XHR.send();
를 보내고 난 때
this.listener = new HttpListener();
listener.Prefixes.Add("http://+:60080/");
listener.Start();
listener.BeginGetContext(HandleRequest, listener);
그래서 내가 HttpListenerContext
HttpListenerContext context = listener.EndGetContext(result);
얻을 http-listener에 사용하여 수신 InputStream (Android 또는 UWP에서)을 얻으려면 항상 null입니다. ContentLength = 0;
iOS InputStream not null에서 테스트 할 때 ContentLength > 0;
무슨 문제입니까?
업데이트 :
나는 내 문제를 해결했다.
사실 내가 Post 메서드를 보냈지 만 실제로 OPTIONS 메서드가 왔습니다.
은 내가 응답 헤더를 보낸 후, 나는 내 문제를 해결 Post 메소드httpListenerContext.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With");
httpListenerContext.Response.AddHeader("Content-type", "application/json");
httpListenerContext.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");
httpListenerContext.Response.AddHeader("Access-Control-Max-Age", "1728000");
httpListenerContext.Response.AppendHeader("Access-Control-Allow-Origin", "*");
httpListenerContext.Response.Close();
을했다? 첫 번째 부분은 JavaScript처럼 보이는데,이 부분은 어디에서 호출됩니까? – Cheesebaron
예,이 js의 첫 번째 부분입니다. 애플리케이션이 웹 뷰에서 시작될 때 호출됩니다. HttpListenerContext 컨텍스트 = listener.EndGetContext (결과); HandleRequest에서 호출됩니다. 나는 내 문제를 해결했다. 업데이트를 참조하십시오. – temiklis
해결책으로 솔루션을 추가하고 24 시간 후에 수락 할 수 있습니까? – Cheesebaron