I'm looking for advice on the best way to accomplish running my C# application as a web app. My app takes a file and some configuration settings as input, it runs some scripts against the file, then outputs a new file.
I want to be able to run this as a web service so that it can be accessed from any OS, by 开发者_Python百科keeping the .exe and referenced DLLs on the backend.
Is there any way to accomplish this? I know I have an option to spin up a virtual server and use RDP, but I want to make it a native web experience.
- Is WCF the solution?
- XAML?
- Does Microsoft have a solution to take an .exe and run it on an IIS web server?
Thank you!
You can do this pretty easily with just a simple web application; you don't need to do much of anything special. Simply invoke your exe with the Process class:
Process myApp = new Process();
myApp.StartInfo.FileName = ConfigurationManager.AppSettings["myAppLocation"];
myApp.StartInfo.CreateNoWindow = true;
myApp.Start();
myApp.WaitForExit();
// Open file and read it
// Additional Info at http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
However, the better choice would simply be to extract that code from your EXE (you likely have the code somewhere) and introduce that as a Class Library for your web project to consume.
Unless there is a reason you absolutely need to keep your existing app as an .exe called in the backend, the easiest solution is to integrate your C# code into a simple ASP.NET web app. You can reference existing DLLs from within the web application to use tem on the server side. Check out a tutorial on making a simple ASP/NET web app, such as:
http://www.kirupa.com/net/helloWorld.htm
Just add an html input field to allow a user to upload the file, and make a download link for the output file.
wcf is a service but not executable thing, you may have a look in Browser WPF application, or Silverlight...
Between both of them , silverlight is highly recommended while it is more heterogeneity. bwpf is easier because just do as what you do when you creating a wpf application but only able to run under IE
http://silverlight.net/ the loading thing is build with silverlight and it is running under IIS ONLY
the browser wpf is your exe and dll thing...
精彩评论