Saravanan Ponnusamy

Saravanan Ponnusamy

  • 356
  • 4.4k
  • 1.1m

how to do Response.Redirect inside task

Jun 29 2018 8:03 PM
here is my code..
 
ObjCancellationTokenSource = new CancellationTokenSource();
CancellationToken token = ObjCancellationTokenSource.Token;
var ObjTask = Task<string>.Factory.StartNew(() =>
{
while (!token.IsCancellationRequested)
{
for(i=0;i<n;i++)
{
----------some operation------
}
Response.Write("<script>alert('Inside Catch.');</script>"); // not firing
Response.Redirect("Home.aspx", false);// raising error or not firing
}
}, token);
 
So, here is my question is...
 
once the loop is finish inside the task im trying to show alert through Response.Write and after i need to redirect my page to another page through Response.Redirect...
 
but both or not working...
 
how can i achive it??
 
if i do both Response.Redirect and Response.Write without using task operation.. its working fine..
 
i googled this .. but in all sites , all are using Console.Write method to show some alert.. i dont want that.. i need to show real javascript alert and redirect the page ....
 
pls dont give any web reference.. give some code...
 
thanks all..

Answers (2)