title: How to get the content type of a file from a redirecting page?
body: <p>I have a application, which logs you on to a website and then downloads some files from that website.  </p>
  
  <p>Although, I have been able to download all the type of files and save them properly except whose link redirects to another page.  </p>
  
  <p>for ex if in the source code of the web page , the link address is written as :-  </p>
  
  <p>"<a href="http://someurl.com/view.php" rel="nofollow">http://someurl.com/view.php</a>", then this link redirects and the download immediately starts(when we click on the link in a web brwoser).   </p>
  
  <p>I have been able to download this file programmatically using <code>HttpWebRequest</code><br>
  and then setting the <code>AllowAutoRedirect = true</code>.  </p>
  
  <p>The problem arises  while saving,  I need to have the extension of the downloaded file(whether it is a word document, pdf file or some other file)  </p>
  
  <p>How should I check that?     </p>
  
  <p>Some of the code which I am using is :-  </p>
  
  <pre><code>     HttpWebRequest request = WebRequest.Create(UriObj) as HttpWebRequest;
       request.Proxy = null;
       request.CookieContainer = CC;
       request.AllowAutoRedirect = true ; 
       request.ContentType = "application/x-www-form-urlencoded";
  </code></pre>