✅ Respond with HTML instead of plaintext
This is my entire app right now - how do I make the entire app use HTML as the content type by default?
5 Replies
instead of the raw string u can use
Results.Text("yourHtml", "text/html", Encoding.UTF8)
(https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.results.text?view=aspnetcore-7.0#microsoft-aspnetcore-http-results-text(system-string-system-string-system-text-encoding))Results.Text Method (Microsoft.AspNetCore.Http)
Writes the utf8Content UTF-8 encoded text to the HTTP response.
yeah but most of my app will return HTML responses
wouldn't that be tiring to do for each one
can i set a default for it
the easiest would be to use something like MVC, razor pages or blazor.
minimal apis is mainly designed for web apis
Add middleware after creating app variable that making your response as html
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.