Skip to content
This repository was archived by the owner on Nov 22, 2018. It is now read-only.

Commit 3343bb4

Browse files
committed
Hosting #86 - Consume WebRootFileSystem
1 parent 1bc4e21 commit 3343bb4

17 files changed

+52
-53
lines changed

samples/StaticFileSample/Startup.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ namespace StaticFilesSample
66
{
77
public class Startup
88
{
9-
public void Configuration(IApplicationBuilder app)
9+
public void Configure(IApplicationBuilder app)
1010
{
1111
app.UseFileServer(new FileServerOptions()
1212
{
1313
EnableDirectoryBrowsing = true,
14-
FileSystem = new PhysicalFileSystem(@"c:\temp")
1514
});
1615
}
1716
}

samples/StaticFileSample/project.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{
2+
"commands": {
3+
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.Urls http://localhost:12345/"
4+
},
25
"dependencies": {
36
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
7+
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
48
"Kestrel": "1.0.0-*",
59
"Microsoft.AspNet.StaticFiles": "1.0.0-*"
610
},
711
"frameworks": {
812
"aspnet50": { },
9-
"aspnetcore50": {}
10-
}
13+
"aspnetcore50": { }
14+
},
15+
"webroot": "wwwroot"
1116
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
3+
<html>
4+
<head>
5+
<meta charset="utf-8" />
6+
<title></title>
7+
</head>
8+
<body>
9+
A static HTML file.
10+
</body>
11+
</html>

src/Microsoft.AspNet.StaticFiles/DefaultFilesExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.AspNet.Builder
1212
public static class DefaultFilesExtensions
1313
{
1414
/// <summary>
15-
/// Enables default file mapping on the current path from the current directory
15+
/// Enables default file mapping on the current path
1616
/// </summary>
1717
/// <param name="builder"></param>
1818
/// <returns></returns>
@@ -22,10 +22,10 @@ public static IApplicationBuilder UseDefaultFiles([NotNull] this IApplicationBui
2222
}
2323

2424
/// <summary>
25-
/// Enables default file mapping for the given request path from the directory of the same name
25+
/// Enables default file mapping for the given request path
2626
/// </summary>
2727
/// <param name="builder"></param>
28-
/// <param name="requestPath">The relative request path and physical path.</param>
28+
/// <param name="requestPath">The relative request path.</param>
2929
/// <returns></returns>
3030
public static IApplicationBuilder UseDefaultFiles([NotNull] this IApplicationBuilder builder, [NotNull] string requestPath)
3131
{

src/Microsoft.AspNet.StaticFiles/DefaultFilesMiddleware.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ public class DefaultFilesMiddleware
2929
/// <param name="options">The configuration options for this middleware.</param>
3030
public DefaultFilesMiddleware([NotNull] RequestDelegate next, [NotNull] IHostingEnvironment hostingEnv, [NotNull] DefaultFilesOptions options)
3131
{
32-
if (options.FileSystem == null)
33-
{
34-
options.FileSystem = new PhysicalFileSystem(Helpers.ResolveRootPath(hostingEnv.WebRoot, options.RequestPath));
35-
}
32+
options.ResolveFileSystem(hostingEnv);
3633

3734
_next = next;
3835
_options = options;

src/Microsoft.AspNet.StaticFiles/DirectoryBrowserExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.AspNet.Builder
1212
public static class DirectoryBrowserExtensions
1313
{
1414
/// <summary>
15-
/// Enable directory browsing on the current path for the current directory
15+
/// Enable directory browsing on the current path
1616
/// </summary>
1717
/// <param name="builder"></param>
1818
/// <returns></returns>
@@ -22,10 +22,10 @@ public static IApplicationBuilder UseDirectoryBrowser([NotNull] this IApplicatio
2222
}
2323

2424
/// <summary>
25-
/// Enables directory browsing for the given request path from the directory of the same name
25+
/// Enables directory browsing for the given request path
2626
/// </summary>
2727
/// <param name="builder"></param>
28-
/// <param name="requestPath">The relative request path and physical path.</param>
28+
/// <param name="requestPath">The relative request path.</param>
2929
/// <returns></returns>
3030
public static IApplicationBuilder UseDirectoryBrowser([NotNull] this IApplicationBuilder builder, [NotNull] string requestPath)
3131
{

src/Microsoft.AspNet.StaticFiles/DirectoryBrowserMiddleware.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ public DirectoryBrowserMiddleware([NotNull] RequestDelegate next, [NotNull] IHos
3131
{
3232
throw new ArgumentException(Resources.Args_NoFormatter);
3333
}
34-
if (options.FileSystem == null)
35-
{
36-
options.FileSystem = new PhysicalFileSystem(Helpers.ResolveRootPath(hostingEnv.WebRoot, options.RequestPath));
37-
}
34+
options.ResolveFileSystem(hostingEnv);
3835

3936
_next = next;
4037
_options = options;

src/Microsoft.AspNet.StaticFiles/DirectoryBrowserOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ namespace Microsoft.AspNet.StaticFiles
1111
public class DirectoryBrowserOptions : SharedOptionsBase<DirectoryBrowserOptions>
1212
{
1313
/// <summary>
14-
/// Enabled directory browsing in the current physical directory for all request paths
14+
/// Enabled directory browsing for all request paths
1515
/// </summary>
1616
public DirectoryBrowserOptions()
1717
: this(new SharedOptions())
1818
{
1919
}
2020

2121
/// <summary>
22-
/// Enabled directory browsing in the current physical directory for all request paths
22+
/// Enabled directory browsing all request paths
2323
/// </summary>
2424
/// <param name="sharedOptions"></param>
2525
public DirectoryBrowserOptions(SharedOptions sharedOptions)

src/Microsoft.AspNet.StaticFiles/FileServerExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static IApplicationBuilder UseFileServer([NotNull] this IApplicationBuild
3838
/// Enables all static file middleware (except directory browsing) for the given request path from the directory of the same name
3939
/// </summary>
4040
/// <param name="builder"></param>
41-
/// <param name="requestPath">The relative request path and physical path.</param>
41+
/// <param name="requestPath">The relative request path.</param>
4242
/// <returns></returns>
4343
public static IApplicationBuilder UseFileServer([NotNull] this IApplicationBuilder builder, [NotNull] string requestPath)
4444
{

src/Microsoft.AspNet.StaticFiles/IHostingEnvironment.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)