I want additional MimeTypes for XML: text/xml, application/xml
Describe the solution you'd like
I would like to skip default serialization when content type is set to anything else that json without using OpenResponseText.
Generally, I would like to return serialized xml string and manually call ToString on XElement.
Better solution is to return XElement or XDocument and let EmbedOI handle serialization and content type like it does with json.
`
<Route(HttpVerbs.Get, "/")>
Public Async Function GetXml() As Task(Of XElement)
Response.ContentType = MimeType.TextXml
Dim elementName As String = "contact"
Dim contact3 As XElement =
<<%= elementName %>>
<name>Hohoho</name>
</>
Return contact3 // XElement or XDocument
End Function
`
Describe alternatives you've considered
The only solution that works is (VB):
`
<Route(HttpVerbs.Get, "/")>
Public Async Function GetXml() As Task(Of String)
Response.ContentType = "text/xml"
Dim elementName As String = "contact"
Dim contact2 =
<contact>
<name>Hohoho</name>
</contact>
Using writer = HttpContext.OpenResponseText()
Await writer.WriteAsync(contact2.ToString())
End Using
End Function
`
Additional context
Dev tools should show correct output
Is your feature request related to a problem? Please describe.
Version 3.5.2.
I have an old API that returns XML and it gets complicated...
It seems that Response.ContentType always returns json.
I've tried:
Response.ContentType = MimeType.Html Response.ContentType = "text/xml"
I want additional MimeTypes for XML: text/xml, application/xml
Describe the solution you'd like
I would like to skip default serialization when content type is set to anything else that json without using OpenResponseText. Generally, I would like to return serialized xml string and manually call ToString on XElement.
Better solution is to return XElement or XDocument and let EmbedOI handle serialization and content type like it does with json.
`
`
Describe alternatives you've considered
The only solution that works is (VB):
`
`
Additional context Dev tools should show correct output