What is the difference between a web service in the same project and a different project in the same project?

Asked

Viewed 553 times

3

Everyone tells me to create a REST and not SOAP. I know I’ll only get it well doing.

I picked up an old project at the company where I’m with a web service in the same project.

As I’m using MVC, I went to create a web service and came across two situations: or I start a new website (A new project in the Solution); or I add a new item (WCF) and create a web service (WCF) in the same project.

I confess I cannot distinguish this difference well, if there is one. What should I really do? Is there a right or more advantageous way to use one approach over the other?

  • 1

    Solution is only a logical grouping of projects, which Visual Studio uses, is similar (not equal) to Eclipse’s Workspace;

3 answers

2

Do the following:

  1. Create a Class Library project for your business
  2. Create a MVC 4 or 5 project for your Website
  3. Create a MVC/Webapi project for your Webservice REST
  4. In your Website and Web Service project make reference to your Business Project (1)
  • I don’t have the Class Library option. I give an Add to Solution and I don’t get the Class Library option

  • @pnet What is your IDE? VS 2012 Web ?

  • 2012 and 2013, but in another forum a friend told me that Class Library is windows form and not web, so I was not finding.

  • It is not Windows Form, E class library, distinct, a project of this type generates a dll that can be used by any other type of project . NET

2

If you are creating REST services, I strongly recommend using Webapi. The concepts are similar to those of ASP.NET MVC, having controllers and actions... and therefore it is easier to reuse your knowledge.

You can create in the same project, no need to start a new project, except for organization reasons.

0

You could create this REST service using WCF or Webapi, both have their peculiarities.

But an interesting question is also about the publication:

Creating a new separate project from your Asp.Net MVC project, whenever your Asp.Net MVC project and REST service are changed and there is a need to update them in a production environment, you need to publish each one. Updating two projects.

Already creating the REST service in your Asp.Net MVC project, whenever you publish your application, you will not need to publish your REST service as well. Updating only the Asp.net MVC project.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.