Asp.net web api 无法从https中的asp.net web api下载.apk文件
我的Asp.net web api 无法从https中的asp.net web api下载.apk文件,asp.net-web-api,asp.net-web-api2,Asp.net Web Api,Asp.net Web Api2,我的Web API代码如下,在http模式下工作,但不在https模式下工作。没有错误显示,只需给我一个http 204状态代码,反正无法下载apk文件,我的服务器是windows 2012。谢谢 using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Net.Http.Head
Web API
代码如下,在http模式下工作,但不在https模式下工作。没有错误显示,只需给我一个http 204状态代码,反正无法下载apk文件,我的服务器是windows 2012。谢谢
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web.Http;
namespace DownloadFileFromWebApi.Controllers
{
[RoutePrefix("download")]
public class DownloadController : ApiController
{
[Route("get_demo_file")]
public HttpResponseMessage GetFileFromWebApi()
{
try
{
var FilePath = System.Web.Hosting.HostingEnvironment.MapPath(@"~/download/app.apk");
var stream = new FileStream(FilePath, FileMode.Open);
HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new StreamContent(stream);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") {
FileName="app.apk"
};
return response;
}
catch
{
return new HttpResponseMessage(HttpStatusCode.NoContent);
}
}
}
}