Edit: Fixed now, apparently API classes cannot be static.
I have a Web API
public sealed class DeploymentController : ApiController
{
[HttpGet]
public static HttpResponseMessage Get([FromUri]Parameters deployment)
{
if (deployment == null) return new HttpResponseMessage(HttpStatusCode.BadRequest);
DeploymentRepository.DetermineExtras(deployment);
HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new StreamContent(DeploymentRepository.GenerateStreamFromString
(DeploymentRepository.GetDeployment(deployment)));
result.Content.Headers.ContentType =
new MediaTypeHeaderValue("application/cmd");
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = "DeployApplication.vbs"
};
return result;
}
}
that returns a file for download when invoked.
This API is supposed to get called by Links the User clicks on.
Like
http://localhost:52998/api/deployment?applicationname=something&systemkind=anotherthing&platformkind=Dotnet
But instead of the File, i get an Error 405.
A first chance exception of type 'System.Web.Http.HttpResponseException' occurred in System.Web.Http.dll
iisexpress.exe Information: 0 : Response, Status=405 (MethodNotAllowed), Method=GET, Url=http://localhost:52998/api/deployment?applicationname=something&systemkind=anotherthing&platformkind=Dotnet, Message='Content-type='application/xml; charset=utf-8', content-length=unknown'
iisexpress.exe Information: 0 : Operation=XmlMediaTypeFormatter.WriteToStreamAsync
I have already tried the methods suggested to similiar questions, so far without success.