Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan Soule 33 posts 194 karma points
    Apr 06, 2022 @ 23:12
    Dan Soule
    0

    Umbraco 9 equivalent of Umbraco 8 Response.AppendHeader

    This works in Umbraco 8

    @inherits Umbraco.Web.Mvc.UmbracoViewPage @using ContentModels = Umbraco.Web.PublishedModels; @using Umbraco.Web.Models; @{ Response.ContentType = "application/CSV";

    // -- Set download file name Response.AppendHeader("content-disposition", string.Format("inline;FileName=\"{0}\"", "Health Catalyst Product List.csv")); }

    Umbraco 9 ??

    @using Umbraco.Cms.Web.Common.PublishedModels; @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage @using Umbraco.Cms.Core.Models; @using Umbraco.Extensions @using TemplateToPdf.Builders; @{ ViewContext.HttpContext.Response.ContentType = "application/CSV";

    // -- Set download file name ViewContext.HttpContext.Response.AppendHeader("content-disposition", string.Format("inline;FileName=\"{0}\"", "Health Catalyst Product List.csv")); }

    My error message is: HttpResponse' does not contain a definition for 'AppendHeader' and no accessible extension method 'AppendHeader' accepting a first argument of type 'HttpResponse'

    I am pretty sure I just don't have the proper command or syntax for the AppendHeader method

    Any help is appreciated.

  • Dan Soule 33 posts 194 karma points
    Apr 08, 2022 @ 19:59
    Dan Soule
    101

    I finally stumbled on the the proper Umbraco 9 function as shown below:

    // -- Set download file name ViewContext.HttpContext.Response.Headers.Add("content-disposition", string.Format("inline;FileName=\"{0}\"", "Health Catalyst Product List.csv"));

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies