Mvc – A good substitute for ASMX web service methods, but not a general handler

ajaxasp.netexceptionsjsonmvc

The best thing I like about ASP.NET MVC, is that you can directly call a server method (called action), from the client. This is so convenient, and so straightforward, that I really like to implement such a model in ASP.NET WebForms too.

However, in ASP.NET WebForms, to call a server method from the client, you should either use Page Methods, or Web Services, both of which use SOAP as their communication protocol (though JSON can also be used).

There is also another substitution, which is using Generic Handlers. The problem with them however is that, a separate Generic Handler should be written for each server method. In other words, each Generic Handler works like a simple method.

Is there anyway else to imitate MVC model in ASP.NET WebForms?

Please note that I can't change to MVC platform right now, cause the project at our hand is a big project and we don't have required resources and time to change our platform. What we seek, is a simple MVC model implementation for our AJAX calls. A problem that we have with Web Services, is the known problem of SoapException, and we're not interested in creating custom SoapExctensions.

Best Answer

You probably pant to check out the wcf web API. Preview 6 dropped yesterday, it looks real promising. If you can't get as experimental as that, one can make WCF web services return POX or JSON rather than SOAP.

You can also integrate MVC into traditional web forms apps without too much trouble. Personally, I like mcv handlers better than traditional services. Though the wcf web API is changing my mind fast.