title: Opening a doc file or PDf file in new tab of browser
body: <p>I have to open a doc file or pdf file in a new tab on click of anchor tag. I am using MVc 4.0.
  The browser tries to open a file in new tab but before that a download screen/pop up opens and restricts the file to open in new tab.I have checked on internet and stackoverflow answers where I was written to do target =_blank but it is not working for me.</p>
  
  <p>I have defined my anchor link as follows. I have file name with me and that will be unique because I am creating the file name using datetime.now.tofiletime(). so, I have given my file name directly. But I first have to detect if the file is document file or PDF file or Image also.Can the below code server this purpose also?Please guide:</p>
  
  <pre><code>&lt;a href="/MyController/ViewDocument?FileName=145357456705009879.docx" target="_blank" title="View Document" style="display:block;" class="ViewDetailClass"&gt; &lt;/a&gt;
  </code></pre>
  
  <p>Then I have below Action method in MyController class.</p>
  
  <pre><code> public ActionResult ViewDocument(string FileName)
      {
          try
          {
              var FullPath = Path.Combine(Server.MapPath("~/Content/Resources"), FileName);
              if (!System.IO.File.Exists(FullPath))
              {
                  return HttpNotFound();
              }
              var contentType = "text/plain";
              return File(FullPath, contentType, Path.GetFileName(FullPath));
          }
          catch
          {
          }
          return File(new byte[] { }, "text/plain");
      }
  </code></pre>