Unable to implement custom IActionResult #26066
Unanswered
SoftCircuits
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to do what I thought would be pretty simple. I want to create my own action result that implements
IActionResult
. Then I want to implementExecuteResultsAsync()
to write XML content tocontext.HttpContext.Response.Body
.The first problem is that the method has to be
async
. I'm thinkingcontext.HttpContext.Response.Body
is probably aMemoryStream
? Either way, I don't see the need for this to run asynchronously and expect performance to suffer if I do.So I instead derived from
ActionResult
, which has a virtual, non-async version of this method. But now I get the exception:So next I set
XmlWriterSettings.Async = 2
, and called only async methods ofXmlWriter
. I hoped the arguments would be the same, but the async methods all have different arguments. So I set all the additional arguments to null.Now I still get the exception:
I don't know where I would call
WriteAsync
, and I'm not sure the ramifications of change the application-wideAllowSynchronousIO
value.Question: How can I implement a custom
IActionResult
and implementsExecuteResultAsync()
and writes XML to the output? What exactly does .NET Core want from me?I'm using VS 2019 v16.7.2, ASP.NET 3.1, Razor Pages.
Beta Was this translation helpful? Give feedback.
All reactions