检查文件类型&在asp.net中重写的URL格式 [英] Check File type & format in rewritten URL in asp.net

查看:105
本文介绍了检查文件类型&在asp.net中重写的URL格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查url是特定文件格式的url。但是url被重写了。那么如何检查输入的URL是PDf文件还是图像URL。意味着我想设置对URL的限制,如果输入的URL不是图像url那么它在asp.net中无效



提前感谢...

解决方案

一般情况下,URL并不真正带有文件格式。在HTTP服务器的基本默认行为中,您可以查看所谓的文件扩展名(它实际上不是扩展名,但文件名遵循某种命名模式),它可以建议文件格式,但仅建议。如果URL被重写,或者更基本的是,如果使用某种服务器端技术,文件名(例如* .aspx)并不能真正告诉您有关文件格式的任何信息(更准确地说,内容)输入: http://en.wikipedia.org/wiki/Content_type [ ^ ])。



它适用于不同的方式:内容类型(参见上面引用的文章)在HTTP响应中规定为HTTP标头之一。客户端软件首先读取此标题,然后选择要用于进一步处理的软件,在浏览器内部处理它,加载一些外部应用程序,建议用户将其作为文件下载,等等。



另请参阅:

http://en.wikipedia .org / wiki / HTTP [ ^ ],

http://en.wikipedia.org/wiki/List_of_HTTP_header_fields [ ^ ](首先,要注意Content-Type,当然),

http://tools.ietf.org/html/rfc1945 [ ^ ]。



-SA

I want to check url is of perticular file format url. But url is rewritten. So how can I check entered url is for PDf file or image url. means I want to set restriction on URL if entered URL is not of image url then its invalid in asp.net

thanks in advance...

解决方案

In general case, URL's don't really carry the file format. In basic default behavior of an HTTP server, you can look at so called "file extension" (which is not really the "extension", but the file name follows certain naming pattern), and it can suggest the file format, but only suggest. If the URL is rewritten, or, more basically, if some server-side technology is used, the "file name" (such as "*.aspx") does not really tell you anything about the file format (more exactly, "content type": http://en.wikipedia.org/wiki/Content_type[^]).

It works in a different way: the content type (see the article referenced above) is prescribed in the HTTP response as one of the HTTP headers. The client-side software first reads this header and then chooses what software to use for further processing, process it internally in the browser, load some external application, suggest the user to download it as a file, and so on.

See also:
http://en.wikipedia.org/wiki/HTTP[^],
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields[^] (first of all, pay attention of "Content-Type", of course),
http://tools.ietf.org/html/rfc1945[^].

—SA


这篇关于检查文件类型&在asp.net中重写的URL格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆