I'm currently working on a system that needs to be able redirect a consumer to a c# application using a form which POSTs data as a serialized JSON string along with the consumer.
So, the form would look something like this, essentially: -
<form action="c#methodLocation" method="post">
<input type="text" value="<?php echo $safeFormatJson; ?>">
<input type="submit" value="submit">
</form>
I would imagine an enctype would be needed, however I've tried "application/json" but the data is interpreted as UrlEncoded. Would text/plain work, or is it even possible to send strictly a serialized string as a POST?
I've tried using Jquery and AJAX to send the data a different way, but that method creates issues with the data being rewritten when the consumer arrives to the c# side, as a new session is inadvertently created when doing so.
The only solution known by me is to catch onsubmit event and then send any hand-made-request you like
Here is pseudode with something jQuery-like (it can be prototype.js, angular.js or pure JS8)
(
var form = $("#myform"); //find needed element in DOM
var mySecretEncription = function(){.../*hard to understand secret*/}; //define your specials
var myPost = function(){ //provide functionality to send valid request
var myData = {};
myData.superField = mySecretEncription(form.select("input.myfield").value);
$.http({
url : "special-post-url or form.action attribute",
method:"POST",
headers:{... my special header ...},
data :myData
})
}
form.on("submit", mypost); //event subscription
)()
It's not code to copy, it's recepie