ASP.Net MVC and Webservices / Ajax - Which Route to Take?

I am developing an ASP.Net mvc application that requires performing small, atomic actions without writing back all over the page. The logical way to do this, of course, is to call ajax.

My question is - What would people offer - the best way to achieve this?

As far as I know, I can do this in the following lines:

  • WCF + ajax
  • Controller actions in mvc application - possibly returned as JSON result.
  • Web Services (stand-alone / combined project) + ajax

I have a requirement that a user logs in using webservice / wcf / ajax, which is currently executed using a cookie / session id, but as far as I know, all of the above methods allow this.

In general, no matter what method I use, there will be access to the database through standardized calls to available methods, so I'm not tied to storing everything in the same project / namespace.

I would like to hear people's thoughts / experiences on this!

+3
source share
2 answers

I would recommend doing this as controller actions. Here's why: you may be able to do the same thing by returning several different views. For example, the GetPerson () action may return Person data as XML, JSON, or HTML (and possibly other views).

This is a general approach in Rails, as well as in ASPMVC.

+3
source

Controller, , :

  • WCF/Webservices ( , WCF/Webservices, )
  • , Javascript . ( , )
  • , , ,

, .

+1

Source: https://habr.com/ru/post/1705850/


All Articles