-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added API demo case for ASP.NET Core 3 + with context.Request.EnableB…
…uffering(); fix (#559) * Added api controller * context.Request.EnableBuffering();
- Loading branch information
1 parent
9342736
commit cc23653
Showing
2 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
examples/ASP.NET Core 3/ASP.NET Core 3 - VS2019/Controllers/ApiController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace ASP.NET_Core_3___VS2019.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class LogTestsController : ControllerBase | ||
{ | ||
private readonly ILogger<LogTestsController> _logger; | ||
|
||
public LogTestsController(ILogger<LogTestsController> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
[HttpPost] | ||
public async Task<ActionResult> TestLog([FromBody]string request) | ||
{ | ||
try | ||
{ | ||
throw new ApplicationException("Test log message"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex, "Test error logging"); | ||
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters