How to send XMLHttpRequest (PUT) request in javascript from aspx page to .aspx in same project and how to write a json response to the put request in .aspx.cs.
This attribute can be only set true or false, and it corresponds to the two request methods Get and Post. This means that WebMethod only accepts these two request methods.
Best regards,
Xudong Peng
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
1 Points
45 Posts
How to send XMLHttpRequest put request from javascript to some.aspx and how to create response in...
Jan 20, 2021 05:38 AM|NatarajYashash|LINK
How to send XMLHttpRequest (PUT) request in javascript from aspx page to .aspx in same project and how to write a json response to the put request in .aspx.cs.
Example:
PUT https://*****.apsx
Content-Disposition: filename="filename.pdf"
Example Response:
<div>HTTP/1.1 200 OK</div> <div>Content-Type: application/json</div> <div> </div> <div>{</div> <div> "uploadUrl": "https://****.apsx",</div> <div> "expirationDateTime": "2015-01-29T09:21:55.523Z",</div> <div> "FileName": "Filename_SessionID.EXT",</div> <div> "UploadSessionID": "***********"</div> <div>}</div>PUT https://****.apsx
Content-Length: 1024
Content-Range: bytes 0-1023/4096
<bytes 0-1023 of the file>
Example Response:
HTTP/1.1 202 Accepted
Content-Type: application/json
{
"expirationDateTime": "2015-01-29T09:21:55.523Z",
"nextExpectedRanges": ["1025"]
}
PUT https://*****.apsx
Content-Length: 1024
Content-Range: bytes 3022-4096/4096
Content-Disposition: filename="filename.jpg"
<bytes 3022-4096 of the file>
Example Final Response:
HTTP/1.1 201 Created
Content-Type: application/json
{
"name": "filename.jpg",
"size": 4096
}
Contributor
2080 Points
664 Posts
Re: How to send XMLHttpRequest put request from javascript to some.aspx and how to create respons...
Jan 21, 2021 07:05 AM|XuDong Peng|LINK
Hi MatarajYashash,
According to your description, I search some articles and documents about this, and I found it can not be implemented in WebForms.
You can see that the WebForm submit method is post in the console element. I tried to use Ajax but I found this document:
ScriptMethodAttribute.UseHttpGet Property
This attribute can be only set true or false, and it corresponds to the two request methods Get and Post. This means that WebMethod only accepts these two request methods.
Best regards,
Xudong Peng