-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates Updates Updates Update
- Loading branch information
Showing
27 changed files
with
378 additions
and
148 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
-16.9 KB
(61%)
aspnetcore/fundamentals/servers/httpsys/_static/vs-choose-profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,3 @@ | ||
{ | ||
"directory": "wwwroot/lib" | ||
} |
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
23 changes: 23 additions & 0 deletions
23
aspnetcore/fundamentals/servers/httpsys/sample/Pages/Error.cshtml
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,23 @@ | ||
@page | ||
@model ErrorModel | ||
@{ | ||
ViewData["Title"] = "Error"; | ||
} | ||
|
||
<h1 class="text-danger">Error.</h1> | ||
<h2 class="text-danger">An error occurred while processing your request.</h2> | ||
|
||
@if (Model.ShowRequestId) | ||
{ | ||
<p> | ||
<strong>Request ID:</strong> <code>@Model.RequestId</code> | ||
</p> | ||
} | ||
|
||
<h3>Development Mode</h3> | ||
<p> | ||
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred. | ||
</p> | ||
<p> | ||
<strong>The Development environment shouldn't be enabled for deployed applications</strong>. It can result in displaying sensitive information from exceptions to end users. For local debugging, enable the Development environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> and restarting the app or adding <code>.UseEnvironment("Development")</code> to <code>WebHost</code> in <i>Program.cs</i> and restarting the app. | ||
</p> |
17 changes: 17 additions & 0 deletions
17
aspnetcore/fundamentals/servers/httpsys/sample/Pages/Error.cshtml.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,17 @@ | ||
using System.Diagnostics; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace HttpSysSample.Pages | ||
{ | ||
public class ErrorModel : PageModel | ||
{ | ||
public string RequestId { get; private set; } | ||
|
||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
|
||
public void OnGet() | ||
{ | ||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
aspnetcore/fundamentals/servers/httpsys/sample/Pages/Index.cshtml
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,28 @@ | ||
@page | ||
@model IndexModel | ||
@{ | ||
ViewData["Title"] = "HTTP.sys Demo"; | ||
} | ||
|
||
<h1>@ViewData["Title"]</h1> | ||
|
||
<div class="row"> | ||
<div class="col-md-6"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Instructions</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<p>Run the app from a command prompt by executing the following command from the project's folder:</p> | ||
<p><code>dotnet run</code></p> | ||
<p>Logging indicates that the <code>HttpSysListener</code> is ready to receive requests:</p> | ||
<p> | ||
<pre><code>info: Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0] | ||
Start | ||
info: Microsoft.AspNetCore.Server.HttpSys.HttpSysListener[0] | ||
Listening on prefix: http://localhost:5000/</code></pre> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
11 changes: 11 additions & 0 deletions
11
aspnetcore/fundamentals/servers/httpsys/sample/Pages/Index.cshtml.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,11 @@ | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
|
||
namespace HttpSysSample.Pages | ||
{ | ||
public class IndexModel : PageModel | ||
{ | ||
public void OnGet() | ||
{ | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
aspnetcore/fundamentals/servers/httpsys/sample/Pages/_Layout.cshtml
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,70 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>@ViewData["Title"]</title> | ||
<environment include="Development"> | ||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css"> | ||
<link rel="stylesheet" href="~/css/site.css"> | ||
</environment> | ||
<environment exclude="Development"> | ||
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css" | ||
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css" | ||
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" | ||
crossorigin="anonymous" | ||
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"> | ||
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true"> | ||
</environment> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-inverse navbar-fixed-top"> | ||
<div class="container"> | ||
<div class="navbar-header"> | ||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | ||
<span class="sr-only">Toggle navigation</span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
</button> | ||
<a asp-page="/Index" class="navbar-brand">HTTP.sys Demo</a> | ||
</div> | ||
<div class="navbar-collapse collapse"> | ||
<ul class="nav navbar-nav"> | ||
<li><a asp-page="/Index">Home</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> | ||
<div class="container body-content"> | ||
@RenderBody() | ||
<hr> | ||
<footer> | ||
<p>©@System.DateTime.Now.Year - HTTP.sys Demo</p> | ||
</footer> | ||
</div> | ||
|
||
<environment include="Development"> | ||
<script src="~/lib/jquery/dist/jquery.js"></script> | ||
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script> | ||
<script src="~/js/site.js" asp-append-version="true"></script> | ||
</environment> | ||
<environment exclude="Development"> | ||
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js" | ||
asp-fallback-src="~/lib/jquery/dist/jquery.min.js" | ||
asp-fallback-test="window.jQuery" | ||
crossorigin="anonymous" | ||
integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk"> | ||
</script> | ||
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js" | ||
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js" | ||
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal" | ||
crossorigin="anonymous" | ||
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"> | ||
</script> | ||
<script src="~/js/site.min.js" asp-append-version="true"></script> | ||
</environment> | ||
|
||
@RenderSection("Scripts", required: false) | ||
</body> | ||
</html> |
3 changes: 3 additions & 0 deletions
3
aspnetcore/fundamentals/servers/httpsys/sample/Pages/_ViewImports.cshtml
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,3 @@ | ||
@using HttpSysSample | ||
@namespace HttpSysSample.Pages | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
3 changes: 3 additions & 0 deletions
3
aspnetcore/fundamentals/servers/httpsys/sample/Pages/_ViewStart.cshtml
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,3 @@ | ||
@{ | ||
Layout = "_Layout"; | ||
} |
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
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,3 @@ | ||
# ASP.NET Core HTTP.sys Sample | ||
|
||
This sample illustrates the use of HTTP.sys. This sample demonstrates the features described in the [HTTP.sys web server implementation](https://docs.microsoft.com/aspnet/core/fundamentals/servers/httpsys) topic. |
45 changes: 28 additions & 17 deletions
45
aspnetcore/fundamentals/servers/httpsys/sample/Startup.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 |
---|---|---|
@@ -1,38 +1,49 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.Hosting.Server.Features; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Http.Extensions; | ||
using Microsoft.AspNetCore.Http.Features; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace HttpSysDemo | ||
namespace HttpSysSample | ||
{ | ||
public class Startup | ||
{ | ||
#region snippet_Configure | ||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
var serverAddressesFeature = app.ServerFeatures.Get<IServerAddressesFeature>(); | ||
|
||
app.UseStaticFiles(); | ||
services.AddMvc(); | ||
} | ||
|
||
app.Run(async (context) => | ||
#region snippet1 | ||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, | ||
ILogger<Startup> logger) | ||
{ | ||
app.Use(async (context, next) => | ||
{ | ||
context.Features.Get<IHttpMaxRequestBodySizeFeature>() | ||
.MaxRequestBodySize = 10 * 1024; | ||
context.Response.ContentType = "text/html"; | ||
await context.Response.WriteAsync("<p>Hosted by HTTP.sys</p>"); | ||
var serverAddressesFeature = app.ServerFeatures.Get<IServerAddressesFeature>(); | ||
var addresses = string.Join(", ", serverAddressesFeature?.Addresses); | ||
if (serverAddressesFeature != null) | ||
{ | ||
await context.Response.WriteAsync($"<p>Listening on the following addresses: {string.Join(", ", serverAddressesFeature.Addresses)}</p>"); | ||
} | ||
logger.LogInformation($"Addresses: {addresses}"); | ||
await context.Response.WriteAsync($"<p>Request URL: {context.Request.GetDisplayUrl()}</p>"); | ||
await next.Invoke(); | ||
}); | ||
|
||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
app.UseDatabaseErrorPage(); | ||
} | ||
else | ||
{ | ||
app.UseExceptionHandler("/Error"); | ||
} | ||
|
||
app.UseStaticFiles(); | ||
app.UseMvc(); | ||
} | ||
#endregion | ||
#endregion | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
aspnetcore/fundamentals/servers/httpsys/sample/appsettings.Development.json
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,10 @@ | ||
{ | ||
"Logging": { | ||
"IncludeScopes": false, | ||
"LogLevel": { | ||
"Default": "Debug", | ||
"System": "Information", | ||
"Microsoft": "Information" | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
aspnetcore/fundamentals/servers/httpsys/sample/appsettings.Production.json
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,10 @@ | ||
{ | ||
"Logging": { | ||
"IncludeScopes": false, | ||
"LogLevel": { | ||
"Default": "Error", | ||
"System": "Information", | ||
"Microsoft": "Information" | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
aspnetcore/fundamentals/servers/httpsys/sample/appsettings.json
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,8 @@ | ||
{ | ||
"Logging": { | ||
"IncludeScopes": false, | ||
"LogLevel": { | ||
"Default": "Debug" | ||
} | ||
} | ||
} |
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,10 @@ | ||
{ | ||
"name": "asp.net", | ||
"private": true, | ||
"dependencies": { | ||
"bootstrap": "3.3.7", | ||
"jquery": "2.2.0", | ||
"jquery-validation": "1.14.0", | ||
"jquery-validation-unobtrusive": "3.2.6" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
aspnetcore/fundamentals/servers/httpsys/sample/bundleconfig.json
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,24 @@ | ||
// Configure bundling and minification for the project. | ||
// More info at https://go.microsoft.com/fwlink/?LinkId=808241 | ||
[ | ||
{ | ||
"outputFileName": "wwwroot/css/site.min.css", | ||
// An array of relative input file paths. Globbing patterns supported | ||
"inputFiles": [ | ||
"wwwroot/css/site.css" | ||
] | ||
}, | ||
{ | ||
"outputFileName": "wwwroot/js/site.min.js", | ||
"inputFiles": [ | ||
"wwwroot/js/site.js" | ||
], | ||
// Optionally specify minification options | ||
"minify": { | ||
"enabled": true, | ||
"renameLocals": true | ||
}, | ||
// Optionally generate .map file | ||
"sourceMap": false | ||
} | ||
] |
25 changes: 25 additions & 0 deletions
25
aspnetcore/fundamentals/servers/httpsys/sample/wwwroot/css/site.css
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,25 @@ | ||
body { | ||
padding-top: 50px; | ||
padding-bottom: 20px; | ||
} | ||
|
||
h1 { | ||
font-size: 24px; | ||
} | ||
|
||
h2 { | ||
font-size: 20px; | ||
} | ||
|
||
h3 { | ||
font-size:16px | ||
} | ||
|
||
.body-content { | ||
padding-left: 15px; | ||
padding-right: 15px; | ||
} | ||
|
||
.panel-body { | ||
font-size: 16px; | ||
} |
1 change: 1 addition & 0 deletions
1
aspnetcore/fundamentals/servers/httpsys/sample/wwwroot/css/site.min.css
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 @@ | ||
body{padding-top:50px;padding-bottom:20px}h1{font-size:24px}h2{font-size:20px}h3{font-size:16px}.body-content{padding-left:15px;padding-right:15px}.panel-body{font-size:16px} |
Binary file not shown.
1 change: 1 addition & 0 deletions
1
aspnetcore/fundamentals/servers/httpsys/sample/wwwroot/js/site.js
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 @@ | ||
// Write your Javascript code. |
Empty file.
Oops, something went wrong.