How to get HttpContext on Radzen project envrionment?

Try to apply

How to get HttpContext on Radzen project envrionment?

public async Task ExportExcel(){

    IWorkbook workbook;
    workbook = new XSSFWorkbook();
    ISheet excelSheet = workbook.CreateSheet("Test");

    IRow row = excelSheet.CreateRow(0);

    row = excelSheet.CreateRow(1);
    row.CreateCell(1).SetCellValue("User 1");


All Radzen applications are generic Blazor (ASP.NET Core ones). All approaches to get HttpContext will work in a Radzen application. Try searching online.

1 Like

If you want to get the context in a controller class then the controller has the current HttpContext as a property.

How about from Radzen generated set, files as follows

Try to cast httpContextAccessor but failed

    [Inject] Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor { get; set; }

The solution from the stackoverflow question won't work in a Blazor page. You cannot stream a file from Blazor. Other than that searching on google for "HttpContext Blazor" returned this:

1 Like