In my .aspx:
public static void DoStuff(XmlDocument doc)
{
HttpResponse response = HttpContext.Current.Response;
string xmlString = doc.InnerXml;
string fileName = "ExportedForm.xml";
response.StatusCode = 200;
response.AddHeader("content-disposition", "attachment; filename=" + fileName);
response.AddHeader("Content-Transfer-Encoding", "binary");
// response.AddHeader("Content-Length", _Buffer.Length.ToString());
response.ContentType = "application-download";
response.Write(xmlString);
}
in my handler.ashx:
private void GenerateXml()
{
var JsonXmlData = HttpContext.Current.Request["objectToSend"];
XmlDocument doc = JsonConvert.DeserializeXmlNode(JsonXmlData);
SystemAuditView.DoStuff(doc); //systemauditview is the .aspx
}
If i call the DoStuff method from a click event it works. But when i call it from code behind, nothing happens. I suppose i somehow need to trigger a postback? Or whats the problem here? Thanks
Try creating object for SystemAuditView and then try to access DoStuff method.
Since DoStuff is a common method you should put this code in App_Code folder.
http://forums.asp.net/t/1291538.aspx