Skip to content

Commit 492620c

Browse files
Fix Content-Disposition header for HTTP reports with non-ASCII output file names. (#965)
1 parent 06421dd commit 492620c

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

dotnet/src/dotnetframework/GxClasses/Model/GXWebProcedure.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace GeneXus.Procedure
66
using System.Globalization;
77
using GeneXus.Http;
88
using GeneXus.Mime;
9+
using System.Net.Mime;
910
#if NETCORE
1011
using Microsoft.AspNetCore.Http;
1112
#else
@@ -14,6 +15,7 @@ namespace GeneXus.Procedure
1415

1516
public class GXWebProcedure : GXHttpHandler
1617
{
18+
static readonly IGXLogger log = GXLoggerFactory.GetLogger<GXWebProcedure>();
1719
protected int handle;
1820

1921
protected GXReportMetadata reportMetadata;
@@ -137,8 +139,19 @@ private void setOuputFileName()
137139
{
138140
fileType = outputType.ToLower();
139141
}
140-
141-
context.HttpContext.Response.AddHeader(HttpHeader.CONTENT_DISPOSITION, $"inline; filename={fileName}.{fileType}");
142+
try
143+
{
144+
ContentDisposition contentDisposition = new ContentDisposition
145+
{
146+
Inline = true,
147+
FileName = $"{fileName}.{fileType}"
148+
};
149+
context.HttpContext.Response.AddHeader(HttpHeader.CONTENT_DISPOSITION, contentDisposition.ToString());
150+
}
151+
catch (Exception ex)
152+
{
153+
GXLogging.Warn(log, $"{HttpHeader.CONTENT_DISPOSITION} couldn't be set for {fileName}.{fileType}", ex);
154+
}
142155
}
143156
}
144157

@@ -152,9 +165,9 @@ protected bool initPrinter(String output, int gxXPage, int gxYPage, String iniFi
152165
if (!Config.GetValueOf("LANGUAGE", out idiom))
153166
idiom = "eng";
154167
fileContentInline = true;
155-
#if NETCORE
168+
156169
setOuputFileName();
157-
#endif
170+
158171
getPrinter().GxRVSetLanguage(idiom);
159172
int xPage = gxXPage;
160173
int yPage = gxYPage;

0 commit comments

Comments
 (0)