### Start HttpRepl connected to localhost example Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/web-api/http-repl/index.md Example command starting HttpRepl connected to a specific base URL. ```console httprepl https://localhost:5001 ``` -------------------------------- ### Start HttpRepl Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/web-api/http-repl/index.md Starts the HttpRepl tool in the terminal after installation. ```console httprepl ``` -------------------------------- ### Start Nginx service Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/host-and-deploy/linux-nginx.md Start the Nginx daemon explicitly after installing it for the first time. ```bash sudo service nginx start ``` -------------------------------- ### Connect command example in HttpRepl Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/web-api/http-repl/index.md Example of connecting to a local web API from a disconnected HttpRepl session. ```console (Disconnected)> connect https://localhost:5001 ``` -------------------------------- ### WebHost.Start(string url, RequestDelegate app) Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/host/web-host.md Initializes and starts a WebHost with default configurations, a specified listening URL, and a custom RequestDelegate handler. ```APIDOC ## WebHost.Start(string url, RequestDelegate app) ### Description Runs the host with a specified URL and a `RequestDelegate`. ### Signature ```csharp public static IWebHost Start(string url, RequestDelegate app) ``` ### Parameters - **url** (`string`) - Required - The URL the server should listen on (e.g., `"http://localhost:8080"`). - **app** (`RequestDelegate`) - Required - The request delegate handler used to process incoming requests. ### Usage Example ```csharp using (var host = WebHost.Start("http://localhost:8080", app => app.Response.WriteAsync("Hello, World!"))) { Console.WriteLine("Use Ctrl-C to shutdown the host..."); host.WaitForShutdown(); } ``` ``` -------------------------------- ### WebHost.StartWith(Action app) Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/host/web-host.md Runs the web host by starting with a delegate that configures an IApplicationBuilder. By default, the application listens on http://localhost:5000. ```APIDOC ## WebHost.StartWith(Action app) ### Description Runs the host by starting with a delegate that configures an `IApplicationBuilder`. The host listens on `http://localhost:5000` by default. ### Signature ```csharp public static IWebHost StartWith(Action app) ``` ### Parameters - **app** (`Action`) - A delegate to configure the application's request pipeline. ### Usage Example ```csharp using (var host = WebHost.StartWith(app => app.Use(next => { return async context => { await context.Response.WriteAsync("Hello World!"); }; }))) { Console.WriteLine("Use Ctrl-C to shut down the host..."); host.WaitForShutdown(); } ``` ``` -------------------------------- ### Install Homebrew on macOS Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/mobile/native-mobile-backend.md Installs Homebrew on macOS via Terminal if it is not already present. Follow the instructions presented by the installer to complete setup. ```Bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### WebHost.Start(RequestDelegate app) Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/host/web-host.md Initializes and starts a WebHost with default configurations and a custom RequestDelegate. Runs listening on default URL http://localhost:5000. ```APIDOC ## WebHost.Start(RequestDelegate app) ### Description Initializes and starts a new host with preconfigured defaults using a `RequestDelegate` handler without requiring a separate `Startup` class. ### Signature ```csharp public static IWebHost Start(RequestDelegate app) ``` ### Parameters - **app** (`RequestDelegate`) - Required - The request delegate handler used to process incoming requests. ### Usage Example ```csharp using (var host = WebHost.Start(app => app.Response.WriteAsync("Hello, World!"))) { Console.WriteLine("Use Ctrl-C to shutdown the host..."); host.WaitForShutdown(); } ``` ``` -------------------------------- ### Inject host services into the Startup constructor Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/startup.md Demonstrates injecting IConfiguration and IWebHostEnvironment into the Startup class constructor. ```csharp public class Startup { private readonly IWebHostEnvironment _env; public Startup(IConfiguration configuration, IWebHostEnvironment env) { Configuration = configuration; _env = env; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { if (_env.IsDevelopment()) { } else { } } } ``` -------------------------------- ### Response from GET /api/todoitems Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/tutorials/first-web-api.md Example JSON response returned when calling the GET /api/todoitems endpoint. ```json [ { "id": 1, "name": "walk dog", "isComplete": true } ] ``` -------------------------------- ### Configure hosting startup assemblies via WebHostDefaults.HostingStartupAssembliesKey Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/host/platform-specific-configuration.md Applies hosting startup assemblies programmatically using UseSetting on the web host builder. The Configure methods run in the order assemblies are listed. ```csharp public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseSetting( WebHostDefaults.HostingStartupAssembliesKey, "{ASSEMBLY1;ASSEMBLY2; ...}") .UseStartup(); }); ``` -------------------------------- ### GET /api/books response example Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/tutorials/first-mongo-app/includes/first-mongo-app-9.md Displays the JSON array response received when executing a GET request on /api/books. ```json [ { "Id": "61a6058e6c43f32854e51f51", "Name": "Design Patterns", "Price": 54.93, "Category": "Computers", "Author": "Ralph Johnson" }, { "Id": "61a6058e6c43f32854e51f52", "Name": "Clean Code", "Price": 43.15, "Category": "Computers", "Author": "Robert C. Martin" } ] ``` -------------------------------- ### WebHost.StartWith(string url, Action app) Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/host/web-host.md Runs the web host by starting with a specified URL and a delegate that configures an IApplicationBuilder. The application responds on the custom URL provided. ```APIDOC ## WebHost.StartWith(string url, Action app) ### Description Runs the host by starting with a specific URL and a delegate that configures an `IApplicationBuilder`. ### Signature ```csharp public static IWebHost StartWith(string url, Action app) ``` ### Parameters - **url** (`string`) - The URL prefix on which the host should listen (e.g., `http://localhost:8080`). - **app** (`Action`) - A delegate to configure the application's request pipeline. ### Usage Example ```csharp using (var host = WebHost.StartWith("http://localhost:8080", app => app.Use(next => { return async context => { await context.Response.WriteAsync("Hello World!"); }; }))) { Console.WriteLine("Use Ctrl-C to shut down the host..."); host.WaitForShutdown(); } ``` ``` -------------------------------- ### Response from GET /api/todoitems/{id} Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/tutorials/first-web-api.md Example JSON response returned when calling the GET /api/todoitems/{id} endpoint for a specific ID. ```json { "id": 1, "name": "walk dog", "isComplete": true } ``` -------------------------------- ### Configure Startup.Configure in ASP.NET Core 2.2 Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/migration/22-to-30.md Example showing Startup.Configure in an ASP.NET Core 2.2 application using UseSignalR and UseMvc. ```csharp public void Configure(IApplicationBuilder app) { ... app.UseStaticFiles(); app.UseAuthentication(); app.UseSignalR(hubs => { hubs.MapHub("/chat"); }); app.UseMvc(routes => { routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}"); }); } ``` -------------------------------- ### Example Azure AD and Downstream API appsettings.json Configuration Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/blazor/security/blazor-web-app-with-entra.md Example JSON configuration showing populated Azure AD and Downstream API properties with concrete GUIDs and endpoints. ```json "AzureAd": { "CallbackPath": "/signin-oidc", "ClientId": "00001111-aaaa-2222-bbbb-3333cccc4444", "Domain": "contoso.onmicrosoft.com", "Instance": "https://login.microsoftonline.com/", "ResponseType": "code", "TenantId": "aaaabbbb-0000-cccc-1111-dddd2222eeee" }, "DownstreamApi": { "BaseUrl": "https://localhost:7277", "Scopes": ["api://11112222-bbbb-3333-cccc-4444dddd5555/Weather.Get"] } ``` -------------------------------- ### WebHost.Start(string url, Action routeBuilder) Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/host/web-host.md Initializes and starts a WebHost configured with a specified URL and routing middleware using an IRouteBuilder action. ```APIDOC ## WebHost.Start(string url, Action routeBuilder) ### Description Runs the host by starting with a specific URL and an instance of `IRouteBuilder`. ### Signature ```csharp public static IWebHost Start(string url, Action routeBuilder) ``` ### Parameters - **url** (`string`) - Required - The URL the server should listen on (e.g., `"http://localhost:8080"`). - **routeBuilder** (`Action`) - Required - Action to configure routing paths and handlers. ### Usage Example ```csharp using (var host = WebHost.Start("http://localhost:8080", router => router .MapGet("hello/{name}", (req, res, data) => res.WriteAsync($"Hello, {data.Values["name"]}!")) .MapGet("buenosdias/{name}", (req, res, data) => res.WriteAsync($"Buenos dias, {data.Values["name"]}!")) .MapGet("throw/{message?}", (req, res, data) => throw new Exception((string)data.Values["message"] ?? "Uh oh!")) .MapGet("{greeting}/{name}", (req, res, data) => res.WriteAsync($"{data.Values["greeting"]}, {data.Values["name"]}!")) .MapGet("", (req, res, data) => res.WriteAsync("Hello, World!")))) { Console.WriteLine("Use Ctrl-C to shut down the host..."); host.WaitForShutdown(); } ``` ``` -------------------------------- ### GET /api/books/{id} response example Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/tutorials/first-mongo-app/includes/first-mongo-app-9.md Displays the JSON object returned when requesting a single book by ID. ```json { "Id": "61a6058e6c43f32854e51f52", "Name": "Clean Code", "Price": 43.15, "Category": "Computers", "Author": "Robert C. Martin" } ``` -------------------------------- ### Sample TenantId and VaultUri values for appsettings.json Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/blazor/security/webassembly/standalone-with-identity/account-confirmation-and-password-recovery.md Example showing a configured TenantId GUID and Azure Key Vault URI with a trailing slash. ```json "TenantId": "00001111-aaaa-2222-bbbb-3333cccc4444", "VaultUri": "https://contoso.vault.azure.net/" ``` -------------------------------- ### WebHost.Start(Action routeBuilder) Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/host/web-host.md Initializes and starts a WebHost configured with routing middleware using an IRouteBuilder action. ```APIDOC ## WebHost.Start(Action routeBuilder) ### Description Runs the host by starting with an instance of `IRouteBuilder` (Microsoft.AspNetCore.Routing), which uses routing middleware. ### Signature ```csharp public static IWebHost Start(Action routeBuilder) ``` ### Parameters - **routeBuilder** (`Action`) - Required - Action to configure routing paths and handlers. ### Usage Example ```csharp using (var host = WebHost.Start(router => router .MapGet("hello/{name}", (req, res, data) => res.WriteAsync($"Hello, {data.Values["name"]}!")) .MapGet("buenosdias/{name}", (req, res, data) => res.WriteAsync($"Buenos dias, {data.Values["name"]}!")) .MapGet("throw/{message?}", (req, res, data) => throw new Exception((string)data.Values["message"] ?? "Uh oh!")) .MapGet("{greeting}/{name}", (req, res, data) => res.WriteAsync($"{data.Values["greeting"]}, {data.Values["name"]}!")) .MapGet("", (req, res, data) => res.WriteAsync("Hello, World!")))) { Console.WriteLine("Use Ctrl-C to shutdown the host..."); host.WaitForShutdown(); } ``` ``` -------------------------------- ### Example URL with SearchString query parameter Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/data/ef-rp/sort-filter-page.md Displays the resulting query string generated when submitting the search form using an HTTP GET method. ```browser-address-bar https://localhost:5001/Students?SearchString=an ``` -------------------------------- ### Configure hosting startup assemblies with HostingStartupAssembliesKey Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/host/generic-host.md Passes a semicolon-delimited list of hosting startup assemblies to load alongside the application assembly during startup. ```csharp webBuilder.UseSetting(WebHostDefaults.HostingStartupAssembliesKey, "assembly1;assembly2"); ``` -------------------------------- ### Run WebHost with WebHost.StartWith(Action) Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/host/web-host.md Runs the host using a delegate that configures an IApplicationBuilder, listening on http://localhost:5000 by default. WaitForShutdown blocks until SIGINT/SIGTERM is received. ```csharp using (var host = WebHost.StartWith(app => app.Use(next => { return async context => { await context.Response.WriteAsync("Hello World!"); }; }))) { Console.WriteLine("Use Ctrl-C to shut down the host..."); host.WaitForShutdown(); } ``` -------------------------------- ### Example DataProtection configuration with versionless Azure Key Vault key Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/blazor/security/blazor-web-app-with-entra.md Example DataProtection section demonstrating Azure Blob Storage and Azure Key Vault endpoints. The key identifier is versionless without a trailing GUID key version to support automatic key rotation. ```json "DataProtection": { "BlobUri": "https://contoso.blob.core.windows.net/data-protection/keys.xml", "KeyIdentifier": "https://contoso.vault.azure.net/keys/data-protection" } ``` -------------------------------- ### Create a new React app with Vite Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/client-side/dotnet-on-webworkers.md Scaffolds a React app with Vite and installs dependencies for .NET 11 or later setups. Select React and JavaScript when prompted. ```bash npm create vite@latest react-app cd react-app npm install ``` -------------------------------- ### Start WebHost with URL and RequestDelegate Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/host/web-host.md Initializes and runs the host with default configuration and a RequestDelegate listening specifically on http://localhost:8080. ```csharp using (var host = WebHost.Start("http://localhost:8080", app => app.Response.WriteAsync("Hello, World!"))) { Console.WriteLine("Use Ctrl-C to shutdown the host..."); host.WaitForShutdown(); } ``` -------------------------------- ### Switch to BookstoreDb database with use Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/tutorials/first-mongo-app/includes/first-mongo-app3-5.md Creates the BookstoreDb database if it does not exist, or opens its connection for transactions if it already exists. ```console use BookstoreDb ``` -------------------------------- ### Set Microsoft Entra Authority and ClientId Example Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/blazor/security/blazor-web-app-with-oidc.md Sets the identity provider authority and client ID using specific Tenant ID and Client ID GUID values. ```csharp oidcOptions.Authority = "https://login.microsoftonline.com/aaaabbbb-0000-cccc-1111-dddd2222eeee/v2.0"; oidcOptions.ClientId = "00001111-aaaa-2222-bbbb-3333cccc4444"; ``` -------------------------------- ### Email confirmation body example for GET /confirmEmail Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/security/authentication/identity-api-authorization.md Default email confirmation body structure generated during registration containing the link with userId, code, and optional changedEmail parameters. ```http Please confirm your account by clicking here. ``` -------------------------------- ### Configure a single request delegate with app.Run in Startup Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/middleware/index.md Sets up a minimal request delegate in Startup.Configure that handles all HTTP requests and terminates the pipeline. ```csharp public class Startup { public void Configure(IApplicationBuilder app) { app.Run(async context => { await context.Response.WriteAsync("Hello, World!"); }); } } ``` -------------------------------- ### HostingAbstractionsHostExtensions.Start Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/host/generic-host.md Launches the host synchronously without waiting for the host to complete before returning. ```APIDOC ## Start ### Description Launches the host synchronously. ### Syntax `public static void Start(this IHost host)` ``` -------------------------------- ### Enable options validation at startup with ValidateOnStart Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/fundamentals/configuration/options.md Configures options validation to run when the app starts during dependency injection setup. Use ValidateOnStart in Program.cs to validate options immediately rather than on first access. ```csharp builder.Services.AddOptions() .Bind(builder.Configuration.GetSection(KeyOptions.Key)) .ValidateDataAnnotations() .ValidateOnStart(); ``` -------------------------------- ### Read environment variables directly in .NET 11 WebAssemblyHostBuilder Source: https://github.com/dotnet/aspnetcore.docs/blob/main/aspnetcore/breaking-changes/11/wasm-env-vars-in-configuration.md Starting in ASP.NET Core 11, WebAssemblyHostBuilder.CreateDefault automatically calls AddEnvironmentVariables, making environment variables accessible from IConfiguration without manual setup. ```csharp var builder = WebAssemblyHostBuilder.CreateDefault(args); // Works without an explicit AddEnvironmentVariables call. var endpoint = builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]; ```