r****y 发帖数: 26819 | 1 Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment; filename=" +
strFileName);
Response.ContentType = "application/octet-stream";
Response.WriteFile(strFileName);
Response.End();
执行没有问题。唯一的问题是,IE总要自动rename这个save as...dialog,给文件名第一
个.之前自动加上[1]。比如文件原名download.mp3,就会变成download[1].mp3.
Firefox就不会这么干。
这可能和.NET无关。怎么避免IE自动rename?应该是可以避免的。因为很多下载都不会
自动加[1]。可能因为这个例子是作为attachment的问题。 |
l*s 发帖数: 783 | 2 There is a bug in IE that the [n] decorations will be inserted to the
filename if it contains two periods. I don't konw if this is what you
encountered.
Or try delete the IE cache.
第一
【在 r****y 的大作中提到】 : Response.Clear(); : Response.ClearContent(); : Response.ClearHeaders(); : Response.AddHeader("Content-Disposition", "attachment; filename=" + : strFileName); : Response.ContentType = "application/octet-stream"; : Response.WriteFile(strFileName); : Response.End(); : 执行没有问题。唯一的问题是,IE总要自动rename这个save as...dialog,给文件名第一 : 个.之前自动加上[1]。比如文件原名download.mp3,就会变成download[1].mp3.
|
c**t 发帖数: 2744 | 3 if you can, detect if file exists first. I don't think that's a bug, it IS a
feature..
【在 l*s 的大作中提到】 : There is a bug in IE that the [n] decorations will be inserted to the : filename if it contains two periods. I don't konw if this is what you : encountered. : Or try delete the IE cache. : : 第一
|
r****y 发帖数: 26819 | 4 It has nothing to do with cache. Say, if you view source of a page, it will
add [1] automatically to the file name showing in notepad.
New question is: if I want to let asp.net download a mp3, instead of showing
save as... prompt, it will automatically be played by windows media player.
How to do this?
【在 l*s 的大作中提到】 : There is a bug in IE that the [n] decorations will be inserted to the : filename if it contains two periods. I don't konw if this is what you : encountered. : Or try delete the IE cache. : : 第一
|
a9 发帖数: 21638 | 5 那跟asp.net无关,跟ie和explorer的设置有关,你改不了的。
或者你用mms协议传
will
showing
.
【在 r****y 的大作中提到】 : It has nothing to do with cache. Say, if you view source of a page, it will : add [1] automatically to the file name showing in notepad. : New question is: if I want to let asp.net download a mp3, instead of showing : save as... prompt, it will automatically be played by windows media player. : How to do this?
|
r****y 发帖数: 26819 | 6 不全是这么回事。
这么说吧,
1:假如我在IE地址栏直接给出一个mp3的http的URL,我的机器表现是,启动
Flashget提示下载,选择cancel以后,windows media player开始播放。
2:但是如果用我前面列出的asp.net代码,就是提示保存attachment, save as。
3:然后另外还有一个http的URL,PHP代码的,在IE地址栏给出以后,直接启动
windows media player开始播放。
我的机器设置没有变,但是这就有三种不同。而这第三种是我想用asp.net做到的。
【在 a9 的大作中提到】 : 那跟asp.net无关,跟ie和explorer的设置有关,你改不了的。 : 或者你用mms协议传 : : will : showing : .
|
a9 发帖数: 21638 | 7 那是因为flashget关联了mp3,把它给截获了。
【在 r****y 的大作中提到】 : 不全是这么回事。 : 这么说吧, : 1:假如我在IE地址栏直接给出一个mp3的http的URL,我的机器表现是,启动 : Flashget提示下载,选择cancel以后,windows media player开始播放。 : 2:但是如果用我前面列出的asp.net代码,就是提示保存attachment, save as。 : 3:然后另外还有一个http的URL,PHP代码的,在IE地址栏给出以后,直接启动 : windows media player开始播放。 : 我的机器设置没有变,但是这就有三种不同。而这第三种是我想用asp.net做到的。
|
r****y 发帖数: 26819 | 8 flashget关联的是所有IE里的URL。
问题是,别人的URL,就没有这个问题,不被Flashget截获,直接播放。
只不过是php代码的,我无法知道怎么写的。
【在 a9 的大作中提到】 : 那是因为flashget关联了mp3,把它给截获了。
|
|
a9 发帖数: 21638 | 9 你看flashget里面有些扩展名的选项的。
【在 r****y 的大作中提到】 : flashget关联的是所有IE里的URL。 : 问题是,别人的URL,就没有这个问题,不被Flashget截获,直接播放。 : 只不过是php代码的,我无法知道怎么写的。
|
a9 发帖数: 21638 | 10 实在不行你就用tcp连接直接请求一下,看看headers里面到底有些啥。
【在 r****y 的大作中提到】 : flashget关联的是所有IE里的URL。 : 问题是,别人的URL,就没有这个问题,不被Flashget截获,直接播放。 : 只不过是php代码的,我无法知道怎么写的。
|
|
|
r****y 发帖数: 26819 | 11 这个我也做了。就用在线的工具:
http://web-sniffer.net/
结果:
HTTP Status Code: HTTP/1.1 200 OK
Date: Mon, 12 Feb 2007 22:58:28 GMT CRLF
Server: Apache/1.3.34 (Unix) mod_ssl/2.8.25 OpenSSL/0.9.7i CRLF
Pragma: CRLF
Cache-Control: max-age=3600, public CRLF
Set-Cookie: CRLF
Expires: Mon, 12 Feb 2007 23:58:28 GMT CRLF
Last-Modified: Mon, 12 Feb 2007 22:58:28 GMT CRLF
ETag: "e00bc8bed4cc7213dc38781fdfe9ce86" CRLF
Content-Length: 1921357 CRLF
Connection: close CRLF
Content-Type: audio/mp3
Content:就是mp3文件
【在 a9 的大作中提到】 : 实在不行你就用tcp连接直接请求一下,看看headers里面到底有些啥。
|
r****y 发帖数: 26819 | 12 用这个做的也一样:
http://www.rexswain.com/httpview.html
Receiving Header:
HTTP/1.1·200·OK(CR)(LF)
Date:·Mon,·12·Feb·2007·23:01:07·GMT(CR)(LF)
Server:·Apache/1.3.34·(Unix)·mod_ssl/2.8.25·OpenSSL/0.9.7i(CR)(LF)
Pragma:·(CR)(LF)
Cache-Control:·max-age=3600,·public(CR)(LF)
Set-Cookie:·(CR)(LF)
Expires:·Tue,·13·Feb·2007·00:01:07·GMT(CR)(LF)
Last-Modified:·Mon,·12·Feb·2007·23:01:07·GMT(CR)(LF)
ETag:·"e00bc8bed4cc7213dc38781fdfe9ce86"(CR)(LF)
Content-Length:·1921357(CR)(LF)
Connection:·close(CR)(LF)
Content-Ty
【在 a9 的大作中提到】 : 实在不行你就用tcp连接直接请求一下,看看headers里面到底有些啥。
|
a9 发帖数: 21638 | 13 这是php的那个?
【在 r****y 的大作中提到】 : 这个我也做了。就用在线的工具: : http://web-sniffer.net/ : 结果: : HTTP Status Code: HTTP/1.1 200 OK : Date: Mon, 12 Feb 2007 22:58:28 GMT CRLF : Server: Apache/1.3.34 (Unix) mod_ssl/2.8.25 OpenSSL/0.9.7i CRLF : Pragma: CRLF : Cache-Control: max-age=3600, public CRLF : Set-Cookie: CRLF : Expires: Mon, 12 Feb 2007 23:58:28 GMT CRLF
|
r****y 发帖数: 26819 | 14 我怀疑人家php代码相当于不是用attachment,而是直接向Response写这个mp3。
【在 a9 的大作中提到】 : 你看flashget里面有些扩展名的选项的。
|
a9 发帖数: 21638 | 15 那你把.net的content-type也改成audio/mp3试试啊。
【在 a9 的大作中提到】 : 这是php的那个?
|
r****y 发帖数: 26819 | 16 这是看http header的工具。
【在 a9 的大作中提到】 : 这是php的那个?
|
r****y 发帖数: 26819 | 17 试过了,因为是attachment,所以没有变化。
【在 a9 的大作中提到】 : 那你把.net的content-type也改成audio/mp3试试啊。
|
a9 发帖数: 21638 | 18 我知道,我是说是不是看的php的页面,呵呵。
【在 r****y 的大作中提到】 : 这是看http header的工具。
|
a9 发帖数: 21638 | 19 去掉Response.AddHeader("Content-Disposition", "attachment; filename=" +
strFileName);这行呢?
【在 r****y 的大作中提到】 : 试过了,因为是attachment,所以没有变化。
|
r****y 发帖数: 26819 | 20 赫赫,这个刚也想到了,试了,好像可以。
【在 a9 的大作中提到】 : 去掉Response.AddHeader("Content-Disposition", "attachment; filename=" + : strFileName);这行呢?
|
|
|
r****y 发帖数: 26819 | 21 对方就是一个上传mp3的php网页。我只是想用asp.net完全仿制。
【在 a9 的大作中提到】 : 我知道,我是说是不是看的php的页面,呵呵。
|
l*s 发帖数: 783 | 22 http://support.microsoft.com/kb/325630
a
【在 c**t 的大作中提到】 : if you can, detect if file exists first. I don't think that's a bug, it IS a : feature..
|
c**t 发帖数: 2744 | 23 这才是关键
【在 a9 的大作中提到】 : 那你把.net的content-type也改成audio/mp3试试啊。
|
c**t 发帖数: 2744 | |