With asp.net, how do I cause a browser to open a tab delimited txt file in Excel?
<p>We have a tab delimited file that we are making available for download. The file extension is txt, but the users want it to open automatically in Excel. The previous developer had used the following code:</p>

<pre><code>private void DownloadLinkButtonCommandEventHandler(object sender, CommandEventArgs e)
{
    Response.ContentType = "Application/x-msexcel";
    var filePath = (string)e.CommandArgument;
    Response.AppendHeader("content-disposition",
                          "attachment; filename=" + filePath);
    Response.WriteFile(filePath);
    Response.End();
}
</code></pre>

<p>The ContentType is being set to Excel, but that doesn't seem to have any effect. I am guessing the txt file extension is causing it to be picked up by notepad or the like instead. I have tried just renaming it to a xls extension, which works but Excel complains that I am trying to trick it or it might be a corrupted file. Any easy win on this? Maybe I should just convert it to an Excel file.</p>
