From 8a10c9800d79cb2a88a6e9bdb9cd4a27f8379d48 Mon Sep 17 00:00:00 2001 From: Luke Latham Date: Wed, 1 Feb 2017 18:26:26 -0600 Subject: [PATCH] Add OnPrepareResponse option w/resp header to static files doc (#2640) * Create StartupAddHeader.cs * Add files via upload * Update static-files.md * Update static-files.md * Update StartupBrowse.cs * Update StartupServeUnknownFileTypes.cs * Update StartupStaticFiles.cs * Update StartupTwoStaticFiles.cs * Update StartupUseFileServer.cs * Update static-files.md --- aspnetcore/fundamentals/static-files.md | 6 ++++ .../static-files/_static/add-header.png | Bin 0 -> 21433 bytes .../static-files/sample/StartupAddHeader.cs | 32 ++++++++++++++++++ .../static-files/sample/StartupBrowse.cs | 4 +-- .../sample/StartupServeUnknownFileTypes.cs | 6 ++-- .../static-files/sample/StartupStaticFiles.cs | 4 +-- .../sample/StartupTwoStaticFiles.cs | 6 ++-- .../sample/StartupUseFileServer.cs | 6 ++-- 8 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 aspnetcore/fundamentals/static-files/_static/add-header.png create mode 100644 aspnetcore/fundamentals/static-files/sample/StartupAddHeader.cs diff --git a/aspnetcore/fundamentals/static-files.md b/aspnetcore/fundamentals/static-files.md index 181c63b5e5..cde50c3d05 100644 --- a/aspnetcore/fundamentals/static-files.md +++ b/aspnetcore/fundamentals/static-files.md @@ -59,6 +59,12 @@ For a request to access *test.png*, configure the static files middleware as fol A request to `http:///StaticFiles/test.png` will serve the *test.png* file. +`StaticFileOptions()` can set response headers. For example, the code below sets up static file serving from the *wwwroot* folder and sets the `Cache-Control` header to make them publicly cacheable for 10 minutes (600 seconds): + +[!code-csharp[Main](../fundamentals/static-files/sample/StartupAddHeader.cs?name=snippet1)] + +![Response headers showing the Cache-Control header has been added](static-files/_static/add-header.png) + ## Static file authorization The static file module provides **no** authorization checks. Any files served by it, including those under *wwwroot* are publicly available. To serve files based on authorization: diff --git a/aspnetcore/fundamentals/static-files/_static/add-header.png b/aspnetcore/fundamentals/static-files/_static/add-header.png new file mode 100644 index 0000000000000000000000000000000000000000..881d4feacb291d61a494c746148019e40441af42 GIT binary patch literal 21433 zcmZ|12RxSj|2KRVrBpPi5UFHGRw5&my+=05UWv@CQd-JPMt1g=QC3t^MnoiAMn<7f zM#lXZsX+Ybk)Y`3bTTY4D%Hi zCo5YAOA^VmCtk~1TWfN^_~O8Vw9?({kCdD=X}2+JN(Wu131j6vvVFJW-6P4}v>LDW zoIg*_@IL7-S#a?62eca8JMU9|p%^`q5`6RN-TRGyzj{Bl|6H~B?ZbL$m&ADPe0*^$ zMeVkokL3k4gs$(*l4ja7bn{(Z{nt^Rvo|PNu8?+bE4Datb?w+D(vqK;7}wESikGBK zo}YGXBh{)rsXck<&Ia|Abd1ra>$f)5x`v%r+IF3WboN@XbUNv*?56AS(X3jeBy!Tl zCi6=pB=r-di){YiK9R1+FU5FoA{jn9Lc1v`jKsXp^6oj3%^6Z|>xKL0NqQ$qG*(J= zBBU=TNGBC^t>j6C&q=i{yLUVzZQDsYsc|=ugGBC4y7>OsF;CL17!r-_oUYg}uKeBO zoLH%tXJX|nBIj=yZad*jp{vWo#NMKCfQ#mo*=DoYvplc8V(9p92vQHtHiVu*zc#JaU2|CW6I)&U zJ@j&zhYHYfX|#I{?{wRU)sM4GE~dey=qS_0X#= zeXn+`UOaV6nx*cw^loWNi|dD6E^_1sNVDJmP{_!6k+c)0*srTFVnH}l5yXn$>y<@@K4#Wg59eE{BzBh=4x#2F2#!;m(A$dN{ z``XMp@{DuhE}KQ}7|B+Ioq12<4_LijCCB&Z#xo7^j-914<(b0tw`5axe6(=oiw)VI z^yH&U3BCA(Q_15Wb8M)4LL_9~ovfWWNFh+?aFVC~jdamz?(GrgO+`m@cjna77hcFE ztGxHyytT-KeD96(wcAgTdq^{zF-ghmDeI|zk{+fmc!{6yj-EXCvCn%$_VMoazAIBF%(C~M3_n|W=w^kYRPFY??XvBcHIGelXFU;= zr#}|a&|_i$j6&oQH#67!z|r{8H=_ch45LTp3@PI;opnxK(i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#^p#v_Lb z1mZK-z~316Gycd7}WI#rLr8yYG;>LCcWa3GH(m<2K3hO+|6+ZhrQU~v|z8gLATV2>iuic}g3 zSb-}No&QaIM36s5zx0nG*T%#y+6n3y!H^_3R<8!`>_tPne*L<^mi}0lB$%IX;oe;6 zR>$~1+9jc((z_Fcyw4$QM z`cck(PhNUzu|PpZV+K0Tu5Qz;@$&_^O%1vas*Ug(vMP#BJduwcbzFP#HGZ4RSbOu_ zOd51w#J?_~v2q)f$lo8up>J2YLre`I55kt{6Yy`YgZT6nn2()HxrSa*vy zg`)5^jRF&K3|qf`#G!@Yo*6=H6R=9MwAhF|Au*>4eGE167Z>AmIP(Jo1Fn7?6~Ha^bbsQCU*$ubn66X($l)8yQV=rE>y2Eb5D|b^ zlu~E*w008PHXsh!hY+El(OV!*o+3r=?|qIHp8)jFU;lrf4pf@_`cuqU&XXMkQQ7os j+r6{QOLFrYTS+GQuQPq(`}W|okVp#WRnO&1UkvzPIIU;r literal 0 HcmV?d00001 diff --git a/aspnetcore/fundamentals/static-files/sample/StartupAddHeader.cs b/aspnetcore/fundamentals/static-files/sample/StartupAddHeader.cs new file mode 100644 index 0000000000..4b8b8cd535 --- /dev/null +++ b/aspnetcore/fundamentals/static-files/sample/StartupAddHeader.cs @@ -0,0 +1,32 @@ +using System.IO; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.Logging; + +namespace StaticFiles +{ + public class StartupAddHeader + { + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + #region snippet1 + public void Configure(IApplicationBuilder app) + { + app.UseStaticFiles(new StaticFileOptions() + { + OnPrepareResponse = ctx => + { + ctx.Context.Response.Headers.Append("Cache-Control", "public,max-age=600"); + } + }); + } + #endregion + } +} diff --git a/aspnetcore/fundamentals/static-files/sample/StartupBrowse.cs b/aspnetcore/fundamentals/static-files/sample/StartupBrowse.cs index 9f70a04790..8c1d1c5116 100644 --- a/aspnetcore/fundamentals/static-files/sample/StartupBrowse.cs +++ b/aspnetcore/fundamentals/static-files/sample/StartupBrowse.cs @@ -20,7 +20,7 @@ namespace StaticFiles // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. #region snippet1 - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app) { app.UseStaticFiles(); // For the wwwroot folder @@ -40,4 +40,4 @@ namespace StaticFiles } #endregion } -} \ No newline at end of file +} diff --git a/aspnetcore/fundamentals/static-files/sample/StartupServeUnknownFileTypes.cs b/aspnetcore/fundamentals/static-files/sample/StartupServeUnknownFileTypes.cs index 72fc457c26..03ba3d399b 100644 --- a/aspnetcore/fundamentals/static-files/sample/StartupServeUnknownFileTypes.cs +++ b/aspnetcore/fundamentals/static-files/sample/StartupServeUnknownFileTypes.cs @@ -14,9 +14,9 @@ namespace StaticFiles // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. #region snippet1 - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app) { - app.UseStaticFiles(new StaticFileOptions + app.UseStaticFiles(new StaticFileOptions() { ServeUnknownFileTypes = true, DefaultContentType = "image/png" @@ -24,4 +24,4 @@ namespace StaticFiles } #endregion } -} \ No newline at end of file +} diff --git a/aspnetcore/fundamentals/static-files/sample/StartupStaticFiles.cs b/aspnetcore/fundamentals/static-files/sample/StartupStaticFiles.cs index 9899dc4cc7..298000f06f 100644 --- a/aspnetcore/fundamentals/static-files/sample/StartupStaticFiles.cs +++ b/aspnetcore/fundamentals/static-files/sample/StartupStaticFiles.cs @@ -17,10 +17,10 @@ namespace StaticFiles // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. #region snippet1 - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app) { app.UseStaticFiles(); } #endregion } -} \ No newline at end of file +} diff --git a/aspnetcore/fundamentals/static-files/sample/StartupTwoStaticFiles.cs b/aspnetcore/fundamentals/static-files/sample/StartupTwoStaticFiles.cs index c1757967ea..53045f1cea 100644 --- a/aspnetcore/fundamentals/static-files/sample/StartupTwoStaticFiles.cs +++ b/aspnetcore/fundamentals/static-files/sample/StartupTwoStaticFiles.cs @@ -17,9 +17,9 @@ namespace StaticFiles // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. #region snippet1 - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app) { - app.UseStaticFiles(); + app.UseStaticFiles(); // For the wwwroot folder app.UseStaticFiles(new StaticFileOptions() { @@ -30,4 +30,4 @@ namespace StaticFiles } #endregion } -} \ No newline at end of file +} diff --git a/aspnetcore/fundamentals/static-files/sample/StartupUseFileServer.cs b/aspnetcore/fundamentals/static-files/sample/StartupUseFileServer.cs index 29239e758b..b9e408a6d3 100644 --- a/aspnetcore/fundamentals/static-files/sample/StartupUseFileServer.cs +++ b/aspnetcore/fundamentals/static-files/sample/StartupUseFileServer.cs @@ -20,9 +20,9 @@ namespace StaticFiles // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. #region snippet1 - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app) { - app.UseStaticFiles(); + app.UseStaticFiles(); // For the wwwroot folder app.UseFileServer(new FileServerOptions() { @@ -34,4 +34,4 @@ namespace StaticFiles } #endregion } -} \ No newline at end of file +}