You could build a webservice in .NET. The best way to do so is with Windows Communication Foundation (WCF).
Then you could write code in your javascript to make calls to the webservice.
Can anyone explain how to send variables from the web (PHP, Javascript, etc.) to a C# program? I want to allow the web to tell the program what to do. Maybe I could use AJAX to send data to an auto-updating page, which the C# program can then read? That would also allow users to be logged-in to the page and therefore different data could be sent to each user. Could someone explain how this could be done?