public static string GetFilename(string docData) { IDocTextInterpreter _IDocDataInterpreter = DocInterpreter.LocateInstance(docData); DocProcessingInstructions _DocProcessingInstructions = _IDocDataInterpreter.ReadDocPI(docData); return(GetFilename(_DocProcessingInstructions, _IDocDataInterpreter)); }
/// <summary> /// DocFileName changes the filename of the response /// </summary> /// <param name="context"></param> public void ProcessRequest(HttpContext context) { try { // ensure the latest content has been processed & imported ImporterController.ImportDocModelsRunOnce(); string docData = Nav.FromQueryParameters(context.Request.Params); IDocTextInterpreter _IDocDataInterpreter = DocInterpreter.LocateInstance(docData); DocProcessingInstructions _DocProcessingInstructions = _IDocDataInterpreter.ReadDocPI(docData); _DocProcessingInstructions.href = BuildHref(context, _IDocDataInterpreter, _DocProcessingInstructions.DocTypeName, _DocProcessingInstructions.solutionVersion); docData = _IDocDataInterpreter.WritePI(docData, _DocProcessingInstructions); context.Response.DisableKernelCache(); context.Response.Clear(); context.Response.ClearContent(); context.Response.ClearHeaders(); context.Response.ContentType = _IDocDataInterpreter.ContentType; context.Response.AddHeader( "content-disposition", string.Format( "attachment; filename=\"{0}\";", GetFilename( _DocProcessingInstructions, _IDocDataInterpreter, context.Request.Params["ContentFileExtension"]))); context.Response.Write(docData); } catch (Exception ex) { context.Response.ClearHeaders(); context.Response.ClearContent(); context.Response.Status = "500 Internal Server Error"; context.Response.StatusCode = 500; context.Response.StatusDescription = string.Format("500 Internal Server Error:\n{0}", ex.AsString()); context.Response.TrySkipIisCustomErrors = true; } }