title: While exporting as csv file, file is getting downloaded but with name and with no extension MVC
body: <p>While exporting as csv file, file is getting downloaded with file name and with no extension MVC the following code is used,</p>
  
  <p>This happens only after deployment to servers, in local its working as expected.</p>
  
  <pre><code> public static KeyValuePair&lt;string, string&gt; ConvertDTtoExcel(DataTable dt, string filename)
              {
                  string fileName = filename + ".csv";
                  string attachment = "attachment; filename=" + fileName;
                  HttpResponse response = HttpContext.Current.Response;
                  try
                  {
                      response.Clear();
                      response.ClearHeaders();
                      response.ClearContent();
                      response.AddHeader("content-disposition", attachment);
                      response.ContentType = "application/csv";
                      response.ContentEncoding = System.Text.Encoding.UTF8;
                      string tab = string.Empty;
                      foreach (DataColumn dc in dt.Columns)
                      {
                          response.Write(tab + dc.ColumnName);
                          tab = ",";
                      }
                      response.Write(Environment.NewLine);
                      int newRow;
                      foreach (DataRow dr in dt.Rows)
                      {
                          tab = string.Empty;
                          for (newRow = 0; newRow &lt; dt.Columns.Count; newRow++)
                          {
                              response.Write(tab + dr[newRow].ToString());
                              tab = ",";
                          }
                          response.Write(Environment.NewLine);
                      }
                      response.Flush();
                      response.End();
                      return new KeyValuePair&lt;string, string&gt;(fileName, response.ContentType);
                  }
                  catch (Exception ex)
                  {
                      Logger.Error(string.Format("Method Name: ConvertDTtoExcel, Error Occurred {0}", ex.ToString()));
                      throw;
                  }
                  finally
                  {
                      HttpContext.Current.ApplicationInstance.CompleteRequest();
                  }
  
              }
  </code></pre>