I think #2 and #3 is good either. With #3, you could create one single action in base controller to accept for form submit AJAX call from client side.
You could also go with #2 and passing all parameter that you need (extract from EPiServer) and manipulate data within your API. EPiServer classes could be inject using built in locator services when you initialize/configure API start up.
#3 is fit for thing that you just need it to work. #2 is fit with more scalibilty when you want to extend your solution later.
Thanks, Dzung Le! Glad I'm on the right track. When you say, "EPiServer classes could be inject using built in locator services when you initialize/configure API start up," which EPiServer classes do you have in mind? Classes used to access EPiServer content? I think the use cases I mentioned above will be EPiServer-agnostic, at least when it comes to CMS content.
I mean some core interfaces and classes that you might want to use to manipulate EPiServer data (page, block, media).
Here is some reference on how to use Web API within EPiServer http://www.frederikvig.com/2012/02/using-the-asp-net-web-api-framework-with-episerver/
Well sorry if this is a duplicate thread. I know I wrote this a couple weeks ago, but now can find no trace of it. I'm working on an MVC EPiServer CMS site. We're trying to build very modular pages. There are a few cases where we want to to have a reusable form that can be dropped onto any page where the submit button submits the form using AJAX. For example, we'd like to have a login form that pops up in a modal dialog that can be used on any page. When you click the submit button, it should do so using an AJAX request. Another example is a partial view that allows a user to sign up for a news letter. The user enters their e-mail address and clicks submit which will AJAX post back to the server to sign them up and then display a confirmation message in place of the original form. Again, this can be placed on any page.
I'm fine on the client-side coding. What I don't know is where to post the forms to. It would be nice to only have to write one controller/action that can be called by the form, but EPiServer doesn't realy seam to support that since it requires a page reference in order to get a URL. The only two options I can think of are 1) add an action method, for the form to post back to, in the controller of each page the form is used on, 2) create a web API method for my form to post to. The downside of #2 is I lose the ability to use some of the stuff in my base page controller. I guess a 3rd option might be to put the action in my base page controller. But I have to imagine this is a frequent practice. How would you recommend doing this?