In Mvc6, where is the WriteAsync function?

The following are examples of creating middleware in Mvc6, and all of the examples use the WriteAsync function. Something like that:

if (HttpContext.Request.Path.Value == "/MyHttpHandler")
{
    HttpContext.Response.WriteAsync("This is my HttpHandler ...");
}

The error I get: HttpResponsedoes not contain a definition for, WriteAsyncand the extension method 'WriteAsync' cannot be found that takes the first type argument HttpResponse.

The project was created in VS2017an ASP.NET 5 web application.

Project Dependence:

"Microsoft.AspNet.Mvc": "6.0.0-rc1-final"

Where is the WriteAsync function?

+6
source share
3 answers

Add dependency:

<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="1.1.1" />

Then in the source code add:

using Microsoft.AspNetCore.Http;
+11
source

. "Microsoft.AspNetCore.Http.Abstractions" "using Microsoft.AspNet.Http;", intellisense .

+1

Consider writing simple middleware. There you can also access and edit the answer.

0
source

All Articles