menes-dotnet/Menes

Enable use ASP.NET Core without MVC

idg10 opened this issue · 1 comments

idg10 commented

We have hosting scenarios (e.g. Service Fabric) in which we'd like to use an ASP.NET Core pipeline but have no particular use for MVC. Currently, the ASP.NET Core support in Menes presumes you are using MVC—HttpRequestExtensions.HandleRequestAsync returns an IActionResult.

IActionResult implies the existence of an action, which in turn implies the existence of a controller. For this reason, the IActionResult processing in MVC can't be used in isolation—you effectively need there to be a controller.

Nothing in Menes needs this, so it would be useful to be able to plumb Menes directly into an ASP.NET Core pipeline that doesn't use MVC.

There is logic that would be required in any ASP.NET Core-based hosting that's currently buried in MVC-specific types, such as this code in OpenApiActionResult:

this.operation.Responses.TryGetResponseForStatusCode(this.openApiResult.StatusCode, out OpenApiResponse response);
HttpResponse httpResponse = context.HttpContext.Response;
httpResponse.StatusCode = this.openApiResult.StatusCode;
this.BuildHeaders(httpResponse, response);
Task task = this.WriteBodyAsync(httpResponse, response);

We would need to refactor this out into common code that can be used either from the IActionResult-based mechanism, or from something that plumbs in directly at the pipeline level.

idg10 commented

Closed by #205