'Reload user control after download file
In one of forms in my webform project, there is a user control. this is what I want to do When user click on "download" button in this user control:
- download file
- change a related record in db (for change user status)
- reload that user control (or whole form) to show information based on new status.
I try this solution but the user control doesn't reload.This is body of onclick event :
Response.Redirect("~/Handlers/DownloadFile.ashx?FilePath=CourseFiles/" + _secondFilePath, false);
_secondFilePath = string.Empty;
CourseDB.ChangeCourseStep(DB.CurrentUser.ID, _lastUnpassedCourseInfo.CourseID, (int)Data.Enums.CourseStep.SecondPartFilesDownloaded);
Response.AddHeader("Refresh", "3; url=~/Profile/SalesEngineeringCourse.aspx");
Response.End();
and this is body of HttpHandler :
public void ProcessRequest(HttpContext context)
{
string filePath = HttpContext.Current.Request.QueryString["FilePath"];
string fileName = filePath.Split('\\').Last();
string fileType = filePath.Split('.').Last();
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = fileType;
response.AddHeader("Content-Disposition",
"attachment; filename = " + fileName);
response.TransmitFile(System.Web.HttpContext.Current.Server.MapPath("~") + filePath);
response.Flush();
}
public bool IsReusable
{
get
{
return false;
}
}
is there any solution for this?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
