Skip to content
Browse files

Merge pull request #136 from daptiv/issue120

Fixed NullRef, serialized DTO can be null
  • Loading branch information...
2 parents 9e24486 + 7268868 commit cba794d187d75f7c23e539f4d71a9a86c2c0172a @mythz mythz committed
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/ServiceStack/WebHost.EndPoints/Formats/HtmlFormat.cs
View
3 src/ServiceStack/WebHost.EndPoints/Formats/HtmlFormat.cs
@@ -41,7 +41,8 @@ public void SerializeToStream(IRequestContext requestContext, object dto, IHttpR
&& httpReq.ResponseContentType != ContentType.JsonReport) return;
// Serialize then escape any potential script tags to avoid XSS when displaying as HTML
- var json = JsonSerializer.SerializeToString(dto).Replace("<", "&lt;").Replace(">", "&gt;");
+ var json = JsonSerializer.SerializeToString(dto) ?? "null";
+ json = json.Replace("<", "&lt;").Replace(">", "&gt;");
var url = httpReq.AbsoluteUri
.Replace("format=html", "")

0 comments on commit cba794d

Please sign in to comment.
Something went wrong with that request. Please try again.