InnerException = Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

asp.net c# entity-framework

Question

my code is

please give me solution...thank you

  bool b = false;
  string str=Server.MapPath("~/Files/"+filepath);


      //  Send the file to the browser
      Response.AddHeader("Content-type", filetype);
      Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);

      Response.TransmitFile(Server.MapPath("~/Files/" + filepath));


      Response.Flush();
      //  HttpContext.Current.ApplicationInstance.CompleteRequest();
       Response.End();

      b = true;
1
0
10/7/2013 7:22:13 AM

Popular Answer

This notification means that the thread is currently executing code, and therefore cannot be used to evaluate the expression.

Use

 HttpContext.Current.ApplicationInstance.CompleteRequest 

Instead of Response.End();

Response.Flush and Response.End does the same thing except Response.End stops execution of the page, and raises the EndRequest event.

Calls to the End methods throw a ThreadAbortException exception when the current response ends prematurely.

2
10/7/2013 8:12:50 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow