Reputation: 23
I'm currently using MVC to fetch data from a HTML POST ajax call. I want to transform my web application to a console application.
Ajax call:
$.ajax({
type: "POST",
url: '/Home/Final/',
dataType: "json",
data: JSON.stringify(response),
contentType: "application/json; charset=utf-8",
success: function () {
$('#messge').html('Response Saved').fadeIn();
},
error: function () {
$('#message').html('Error occured').fadeIn();
}
MVC code:
[HttpPost]
public ActionResult Final(Something thing)
{
saveSomething(thing);
return null;
}
In other words, I currently call selenium to automatically fill some information on a website which then makes a POST call back to a MVC controller. Entity Framework works with or without MVC anyways.
I want to change my application to an .EXE so that I can call it periodically.
Is this possible?
Upvotes: 0
Views: 1696
Reputation: 3033
Create a powershell script which invokes a web request to your controller by using Invoke-WebRequest function.
Invoke-WebRequest -ContentType application/json -Method POST -Uri https://yoururl
Then create a scheduled task in your web server and call that powershell script every 5 minutes
powershell -command "C:\Sample.ps1"
Upvotes: 0
Reputation: 616
read this post
http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api
i hope that helps you
Upvotes: 1