current situation: an ASP.NET MVC web site with a number of controllers and action methods, and views to allow adding recipes.
Now, I have to create a WPF application that acts as a UI to add recipes (same as the web site).
My question is: can I use ASP.NET MVC site to expose service operations that are consumed by the WPF application (and how can this be done)? Or should I better create dedicated WCF services for that, and have the WPF AND the ASP.NET MVC site consume these services?
Thanks, Ludwig
ASP.NET MVC Action Methods are responsible to execute requests and generate responses to it. By default, it generates a response in the form of ActionResult. Actions typically have a one-to-one mapping with user interactions.
There are two methods in Action Result. One is ActionResult() and another one is ExecuteResult().
You can specify an action via the MVC namespace. When given a Controller, such as HomeController : public class HomeController : Controller { public ActionResult Index() { ... } public ActionResult MyAction() { ... } public ActionResult MyActionWithParameter(int parameter) { ... } }
I have successfully used MVC controllers and actions to service both HTML views from the browser, as well as external applications. It works well, but as it stands you'd need a little bit of tooling:
However, you could avoid some of this extra tooling if you go the WCF-REST route. Better yet, I'd look into ASP.NET MVC 4's WebApi feature (which is what I will be migrating to).
For the record, I think WCF is powerful, but our organization has grown tired of how complicated it can be to turn all the knobs and hit all the switches to get it working right, and set up easily from one install to the other. MVC, on the other hand, just works... and since we already use it to service our HTML views, it's a real joy to only have to add a little extra code to have it handle service calls, too. Just a personal preference, of course.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With