当前位置: 移动技术网 > IT编程>开发语言>.net > ASP:Response.ContentType

ASP:Response.ContentType

2019年01月19日  | 移动技术网IT编程  | 我要评论

2011法网女单决赛,美贝街,克拉玛依油城信息港

response.contenttype 是用来控制输出的文件类型的。

服务器送给客户端的数据包类型可以是text/html文本,也可以是gif/jpeg图形文件,所以每次传输前,我们都必须告知客户端将要传输的文件类型,一般默认情况下为“text/html”类型。
<% response.contenttype = "text/html" %>
<% response.contenttype = "image/gif" %>
<% response.contenttype = "image/jpeg" %>

用于作为文本内容返回而不是已解释的 html 语句
response.contenttype = "text/plain"
<%
response.contenttype = "text/plain"
response.write(now()&"会被执行么?")
%>

你可以注意到:页面提供下载,页面中的asp内容被解释执行了的程序文件以xls文件被提供下载
response.contenttype = "application/vnd.ms-excel"
<%
response.contenttype = "application/vnd.ms-excel"
response.write("本页面调试会出现下载对话框提供下载,保存类型为xls")
%>

实现歌曲连续播放
response.contenttype="audio/x-pn-realaudio"
<%
dim ramstr
ramstr=""
set rs=server.createobject("adodb.recordset")
sql="xxxxxxxxxxx"
rs.open sql,conn,1,3 conn已定义
do while not rs.eof
ramstr=ramstr&rs("url")&vbcrlf
rs.movenext
loop
rs.close
response.contenttype="audio/x-pn-realaudio"
response.contenttype="audio/x-mpegurl"
response.write ramstr
%>

response.write 输出的时候,由于定义了response.contenttype 所以输出歌曲地址的时候会自动调用符合相应格式的软件来播放歌曲,不过前提是播放歌曲的软件必须先安装的。response.write 输出的时候,由于定义了response.contenttype 所以输出歌曲地址的时候会自动调用符合相应格式的软件来播放歌曲,不过前提是播放歌曲的软件必须先安装的。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网