我遇到问题,我无法从$ http响应的标头中获取文件名
HTTP/1.1 200 OK
Content-Length:121257
Content-Type:application/pdf
服务器:Microsoft-HTTPAPI/2.0
Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:*
Content-Disposition:attachment; filename = Order-414.pdf
日期:星期三,2015年2月11日05:32:25 GMT
我只想在下载时获取文件名(Order-414.pdf)作为pdf名称.但是在这个代码块中:
$http.get(httpPath, { responseType: 'arraybuffer' })
.success(function (data, status, headers) {
debugger;
// just return content-type
var header = headers();
Run Code Online (Sandbox Code Playgroud)
header对象只包含content-type.
Object {content-type: "application/pdf"}
Run Code Online (Sandbox Code Playgroud)
我在某处读到我们需要为WebAPI配置CORS:
private static void RegisterCorsConfig(HttpConfiguration config)
{
var cors = new EnableCorsAttribute("*", "*", "*", "*");
//var cors = new EnableCorsAttribute("*", "*", "*", "DataServiceVersion, MaxDataServiceVersion");
//cors.ExposedHeaders.Add("*");
//cors.ExposedHeaders.Add("filename");
config.EnableCors(cors);
}
Run Code Online (Sandbox Code Playgroud)
但它仍然无效.请帮我.提前致谢.
我有这样的Odata结果
{"odata.metadata":"https://localhost/DocTalkMobileWebApiOData/odata/$metadata#MasterPatient/@Element","PatUniqueId":"39e713db-6a0e-4e59-bf7b-033f4fc47ad5", "PatID":null,
"pat_lname":"White","pat_fname":"Peter","pat_mi":" ","pat_ssn":"270787655","pat_dob":"08/07/1973","pat_sex":"M","pat_status":null,"priInsID":2,"secInsID":1,"PCPID":1,"InternalDrID":1,"EXPID":1,"EXPDate":"","pat_phone":null,"isNew":true,"imported":true,"byWhom":"dt","lastUpdate":"2011-03-30T09:41:57.36","changeStamp":"AAAAAAAAIUE=","address":"","city":"","state":"","zip":"","currentMcp":"","currentVisitCount":-2,"otherId":"543674","pcpName":null,"hasChanges":true,"ProgramSource":null,"mrnID":"","createdBy":null,"createdDate":"2007-10-26T10:16:15","expLocation":null,"ethnicId":1,"prefLanguageId":1,"raceId":1
}
Run Code Online (Sandbox Code Playgroud)
我试图通过kendo.ui.datasource得到这个结果:
newPatient = new kendo.data.DataSource({
type: 'odata', // <-- Include OData style params on query string.
transport: {
read: {
url: url + '/MasterPatient(guid\'00000000-0000-0000-0000-000000000000\')', // <-- Get data from here
dataType: "json" // <-- The default was "jsonp"
},
parameterMap: function (options, type) {
var paramMap = kendo.data.transports.odata.parameterMap(options);
delete paramMap.$inlinecount; // <-- remove inlinecount parameter.
delete paramMap.$format; // <-- remove format parameter.
return paramMap;
}
},
schema: {
data: function (data) {
return data; …Run Code Online (Sandbox Code Playgroud) 我是Xamarin的新手,在尝试使用Android Emulator运行Xamarin App时遇到困难.
这是我的AVD:
我可以运行这个AVD很好但很慢,如果我检查使用主机GPU,它要快得多,但需要很长时间才能启动模拟器.但是当我在Xamrin上调试时,它总是在模拟器中显示此错误:
unfortunately launcher3 has stopped
Run Code Online (Sandbox Code Playgroud)
或只是加载,永远不会像这样完成:
请帮我.