Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
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...
Posted
Comments
Sergey Alexandrovich Kryukov 25-Jun-14 3:04am    
The question is: why? This is not how Web is supposed to be used. I explained the situation in my answer, please see it. If you explain your ultimate goals, I'll try to answer what to do practically, or some other member will do it for you.
—SA

1 solution

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
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900