Since you have WebApi to fetch the data then IMHO creating a webservice just to submit the data is not needed. Unless there is a valid reason you can use WebApi itself to push the value.
Sample Implementation
Sample Class(You can create this as per your design like a Customer, Employee etc
public class SampleClass
{
public string Empname { get; set; }
}
Now add a Post method to your controller
public class SampleController : ApiController
{
[HttpPost]
public void PostData(SampleClass sampleClass)
{
}
}
To call this function from Aspx page you can use Jquery Ajax or Angular or any similar option available. I have used Jquery ajax
<script>
//Get the Json value
//Here you need to have the WebApi call get the results
var SampleJsonValue = { Empname: "SampleJsonValue" };
function SubmitData() {
$.ajax({
type: 'POST',
//Here change the path(Method name and controller name) accordingly
url: '/api/Sample/PostData',
data: JSON.stringify(SampleJsonValue),
contentType: 'application/json; charset=utf-8',
dataType: 'json'
});
}
</script>
Thanks,
A2H
My Blog
Ssagard, if this helps please login to Mark As Answer. | Alert Moderator