0

I have to replicate a MVC4 WebAPI application but mine will just echo the data being sent to it, so I'm wondering if I should just go with a simpler WCF service, because MVC4 WebAPI application has lots of files. The exposed API is very simple:

public Task<HttpResponseMessage> PostData(HttpRequestMessage requestMessage)

I have three questions:

  1. Is it possible to get rid of all the extra .js and other files from MVC4 WebAPI, since I only need to expose an API and don't need any views?
  2. If I were to port this to WCF, what would the signature look like?

    [OperationContract] HttpResponseMessage PostData(HttpRequestMessage request)

  3. Is it worth writing the echo service in WCF?

tunafish24
  • 2,288
  • 6
  • 28
  • 47

1 Answers1

2

Don't use WCF for this... and I happen to have liked WCF in its time so this is not a hater telling you this.

If you have a lot of files in your MVC4 WebAPI project I'm not sure what went wrong. You don't need any /Content or /Views at all. You pretty much just need the /Controllers/MyController.cs file itself and something mapping you a route to it which should be in the default /App_Start/WebApiConfig.cs.

Drew Marsh
  • 33,111
  • 3
  • 82
  • 100
  • It'll be really nice, if you can provide a reason in MVC4 WebAPIs favor. I'm not sure why it's creating files either I just selected WebAPI when creating the project, but it has themes, javascripts etc - which doesn't make sense. – tunafish24 Feb 19 '13 at 21:19
  • Well yeah, that's just the default project template for ASP.NET WebAPI in Visual Studio. They assume you might want a homepage to describe your API and start setting up the API help stuff so they include that for you. Like I said you can remove that. If you want a comparison of a WCF REST service to WebAPI I can do that, but you can find many such examples out there already. – Drew Marsh Feb 19 '13 at 21:40