0

I think about changing my MVC5 - project to WebApi, because it IS already an API returning mainly Json and containing no views.

The good thing is that I already have a base Controller which all others derive from. So all I have to change is "Controller" to "ApiController"

But now I found out that some basic elements are missing. I am not surprised about "OnActionExecuting()" or "Initialize()" missing as they might have different headers in WebApi, but especially the following objects/properties/methods are missing and needed by my code:

Response 
Url.RouteUrl()
Request.Files[]

Are there any equivalents in WebApi? Or is my approach meant to fail and I need to start completely from scratch when using WebApi instead of just "converting" my MVC - project?

Ole Albers
  • 8,715
  • 10
  • 73
  • 166
  • have you googled or searched stackoverflow for the individual items you need addressed? eg for `Response` you can use `System.Net.Http.HttpResponseMessage` if you want to set headers and/or object responses. I cannot confirm but fairly certain that there will be a way to address the other two issues too and in general anything you can do on mvc you will be able to do in web api (perhaps even in a better way, as is `HttpResponseMessage`) – wal May 30 '16 at 10:44
  • eg `Request.Files[]` see webapi equivalent http://stackoverflow.com/questions/10320232/how-to-accept-a-file-post-asp-net-mvc-4-webapi – wal May 30 '16 at 10:47

0 Answers0