Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an asp.net mvc application also have a web service?

I have an asp.net mvc application and now I need to add a web service to go along with it. What is the best solution for this? Just create a new web service project and add it to my solution then deploy it to the same web server using a different url? I would like it to be a part of the mvc application only because I have all my database code in there.

Any suggestions would be appreciated. Thanks.

like image 858
Mike Roosa Avatar asked Apr 25 '09 02:04

Mike Roosa


People also ask

What is web service in ASP.NET MVC?

Web Services are used for enabling an application to invoke a method of another application. These applications can either be on the same computer or on different computers. Web Services use protocols like HTTP, XML, and SOAP.

Can we use Web API with MVC?

You can mix Web API and MVC controller in a single project to handle advanced AJAX requests which may return data in JSON, XML or any others format and building a full-blown HTTP service. Typically, this will be called Web API self-hosting.

Is it possible to create web application with both webforms and MVC?

Luckily, the answer is yes. Combining ASP.NET Webforms and ASP.NET MVC in one application is possible—in fact, it is quite easy. The reason for this is that the ASP.NET MVC framework has been built on top of ASP.NET.


1 Answers

There's no reason not to add a web service project.

You state that all your database code is in your MVC project. I strongly recommend you remove it from there into a separate class library project. This third project would be used both by the web service and by the MVC application.

I also strongly recommend that you not use ASMX web services for any new development.

Use WCF only, unless you have no choice at all. There's a misconception that WCF services don't do SOAP - they do, and WCF has replaced ASMX.

like image 157
John Saunders Avatar answered Sep 22 '22 05:09

John Saunders