Facing issue in MVC 3.0 " Server cannot set status after HTTP headers have been sent. " RRS feed

  • Question


    Hi All,

    Good Day !!

    I am getting "Server cannot set status after HTTP headers have been sent." error while executing the Controller Action method in MVC 3.0. Please see the below code sample for the reference.

    Please someone help me how to fix or avoid this error execution in MVC Controller Action Method?

    Thanks in advance.

       public ActionResult SampleMethod1()

                    Response.AppendHeader("Content-Disposition", "attachment; filename=example10.xml");
                    //Response.AddHeader("Refresh", "3; url=index.html");
                    Response.AddHeader("Refresh", "3");

                   return new JavaScriptResult { Script = "alert('Saved successfully');" };                   


    • Moved by CoolDadTx Thursday, September 20, 2018 1:48 PM ASP.NET related
    Thursday, September 20, 2018 1:04 PM

All replies