Ich kann wirklich nicht verstehen, warum es nicht funktioniert. Ich habe den folgenden Code:ASP.NET Web Api 2 Routing-Problem
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
[RoutePrefix("api/Profile")]
[System.Web.Http.AuthorizeAttribute]
[IdentityBasicAuthenticationAttribute]
public class ProfileApiController : ApiController
{
[HttpPost]
[ValidateApiContentLength]
[ValidateApiMimeMultipart]
[Route("Upload")]
public async Task<HttpResponseMessage> UploadDocumentAsync(string description)
{
//....
}
}
}
aber wenn ich rufe: http://localhost:11015/api/profile/Upload
ich Fehler 404:
{
"Message": "No HTTP resource was found that matches the request URI 'http://localhost:11015/api/profile/Upload'.",
"MessageDetail": "No action was found on the controller 'ProfileApi' that matches the request."
}
aber Einsicht sagt über Fehler:
Was ist falsch?
1. Wie haben Sie den Anruf gemacht? 2. Welche Vorlage verwenden Sie für das Projekt: asp mvc oder asp mvc web api? – CodingYoshi