TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ankit Kumar
NA
159
48.6k
Http Context is not Working
Aug 21 2017 4:43 AM
public void ExporttoExcel(DataTable table)
{
try
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.Write(@"");
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=EmployeeList.xls");
HttpContext.Current.Response.Charset = "utf-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
HttpContext.Current.Response.Write("");
HttpContext.Current.Response.Write("");
HttpContext.Current.Response.Write("");
int columnscount = table.Columns.Count;
for (int j = 0; j < columnscount; j++)
{
HttpContext.Current.Response.Write("
");
}
HttpContext.Current.Response.Write("
");
foreach (DataRow row in table.Rows)
{
HttpContext.Current.Response.Write("
");
for (int i = 0; i < table.Columns.Count; i++)
{
HttpContext.Current.Response.Write("
");
}
HttpContext.Current.Response.Write("
");
}
HttpContext.Current.Response.Write("
");
HttpContext.Current.Response.Write("");
HttpContext.Current.Response.Write(table.Columns[j].ToString());
HttpContext.Current.Response.Write("");
HttpContext.Current.Response.Write("
");
HttpContext.Current.Response.Write(row[i].ToString());
HttpContext.Current.Response.Write("
");
HttpContext.Current.Response.Write("");
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}
catch (Exception ex)
{
}
I am using Above Code For Downloading the File.
File is not Download Automatically Response .context is not Working Well.
Please suggest me if there is any one user is online .
Reply
Answers (
2
)
calculation between two properties from different models
Check 3D rectangle intersection