action 속성이없는 asp.net 양식이 있는데 제출은 ajax에서 다음과 같이 처리합니다.asp 페이지를 다른 URL로 리디렉션
코드$.ajax({
url: "home2.aspx/DoSubmit",
type: "POST",
contentType: "application/json; charset=utf-8",
data: '{x: "' + $("#x").val() + '",y: "' + $("#y").val() + '"}',
dataType: "json",
success: function (result)
{
alert("success...");
},
error: function (xhr, status) {
alert("Error", status);
}
});
return false;
});
뒤에 아약스 호출에 대한 관련 응답을 제공 한 후 내가 백엔드에 존재했다 다른 매개 변수와 다른 URL (심지어 다른 도메인)에 asp.net 페이지를 리디렉션 할. HttpWebRequest를 만들지 만 작동하지 않는이 메서드를 테스트합니다.
var postData = (requestParam.ToString());
var data = Encoding.ASCII.GetBytes(postData);
HttpWebRequest request;
try
{
request = (HttpWebRequest)HttpWebRequest.Create("https:someDomain");
}
catch (UriFormatException)
{
request = null;
}
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
Stream postStream = request.GetRequestStream()
postStream.Write(data, 0, data.Length);
postStream.Flush();
postStream.Close();
이 오류이 원인 : 원격 상대방이 전송 스트림을 폐쇄했기 때문에 인증에 실패했습니다.
감사합니다.
오류가 발생하는 라인은 무엇입니까? 이미 아약스 발신자에게 다시 돌아오고 있다고 말했을 때, 돌아온 후에 어떻게 처리하고 있습니까? –