Add conceptual docs on accessing HttpContext (#771)
* Add doc with sample on accessing HttpContext * Apply suggestions from PR review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
ab6d3e1ac5
commit
39b0ed3c18
1 changed files with 288 additions and 2 deletions
26
docs/concepts/httpcontext/samples/Program.cs
Normal file
26
docs/concepts/httpcontext/samples/Program.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using HttpContext.Tools;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddMcpServer()
|
||||
.WithHttpTransport()
|
||||
.WithTools<ContextTools>();
|
||||
|
||||
// <snippet_AddHttpContextAccessor>
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
// </snippet_AddHttpContextAccessor>
|
||||
|
||||
builder.Logging.AddConsole(options =>
|
||||
{
|
||||
options.LogToStandardErrorThreshold = LogLevel.Information;
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.MapMcp();
|
||||
|
||||
app.Run();
|
||||
Loading…
Reference in a new issue