Use dotnetbrowser.I intercept ajax but how to get ajax POST data content.
Asked
Active
Viewed 154 times
1 Answers
0
In order to intercept the post data of the URL request, you need to override the 'OnBeforeURLRequest' method of the 'DefaultNetworkDelegate' class. In this method, you need to cast the post data to the appropriate data type and then get or set the key-value pairs of this data.
The following sample demonstrates how to intercept, print and modify the form data.
class AjaxNetworkDelegate : DefaultNetworkDelegate
{
public override void OnBeforeURLRequest(BeforeURLRequestParams parameters)
{
if (parameters.PostData != null && parameters.PostData.ContentType == PostDataContentType.FORM_URL_ENCODED)
{
FormData formData = (FormData) parameters.PostData;
foreach (string pairKey in formData.GetPairKeys())
{
Console.WriteLine("Key: " + pairKey);
foreach (string pairValue in formData.GetPairValues(pairKey))
{
Console.WriteLine("Value: " + pairValue);
}
}
formData.SetPair("somekey", "someValue");
parameters.PostData = formData;
}
}
}
Also, the following article demonstrates how to work with different post data types: https://dotnetbrowser.support.teamdev.com/solution/articles/9000110170-modifying-post-put-patch-upload-data

Eugene Yakush
- 259
- 4
- 6