I need to enable image loading in my AngularJS + WebAPI project. for this I use ng-file-upload according to this code example: http://monox.mono-software.com/blog/post/Mono/233/Async-upload-using-angular-file-upload-directive- and-net-WebAPI-service /
with a few zip code settings to look like this:
$scope.onFileSelect = function ($files) { console.log("on file select is running!"); //$files: an array of files selected, each file has name, size, and type. for (var i = 0; i < $files.length; i++) { var $file = $files[i]; (function (index) { Upload.upload({ url: "/api/Uploads/Upload", // webapi url method: "POST", file: $file }).progress(function (evt) { // get upload percentage console.log('percent: ' + parseInt(100.0 * evt.loaded / evt.total)); }).success(function (data, status, headers, config) { // file is uploaded successfully console.log(data); }).error(function (data, status, headers, config) { // file failed to upload console.log(data); }); })(i); } }
I already have several web API controllers, and I added a new one according to the sample code in the link above (which inherits from System.web.http.ApiController instead of the "regular" class Microsoft.AspNet.Mvc.Controller ):
[Route("api/[controller]")] public class UploadsController : ApiController { [HttpPost]
The problem is that I keep getting “404 not found” when posting.
I tried:
Please, help! thanks!
EDIT
this is the tab of the "Network" browser: 
EDIT2
my routes:
app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); });
these are only announced routes.
EDIT3
I am 100% sure that the problem is using the " ApiController " as the base class instead of the " Controller ". I have added a new controller and I cannot get any problems to it. now just making it work, since I don't have “Request.Content” in “ Controller ” - any ideas?
I see two possibilities to do this:
but I get HTTP 500 as I don’t know how to switch from angular POST.
or
- get Request.Content for the solution in the controller (I don’t know how).
did anyone manage to do this? thanks!