Skip to content

Instantly share code, notes, and snippets.

@koistya
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koistya/9951731 to your computer and use it in GitHub Desktop.
Save koistya/9951731 to your computer and use it in GitHub Desktop.
Katana/Owin StaticFiles Usage Scenario

Directory layout:

.
├── bin
├── public
│   └── test.txt
├── packages.config
├── Startup.cs
├── Web.config
└── Project.csproj

Scenarios:

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Owin" version="3.0.0-beta1" targetFramework="net451" />
<package id="Microsoft.Owin.FileSystems" version="3.0.0-beta1" targetFramework="net451" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.0-beta1" targetFramework="net451" />
<package id="Microsoft.Owin.StaticFiles" version="3.0.0-beta1" targetFramework="net451" />
<package id="Owin" version="1.0" targetFramework="net451" />
</packages>
using Microsoft.Owin;
using Microsoft.Owin.Extensions;
using Microsoft.Owin.FileSystems;
using Microsoft.Owin.StaticFiles;
using Owin;
[assembly: OwinStartup(typeof(Web.Startup))]
namespace Web
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseFileServer(new FileServerOptions
{
EnableDirectoryBrowsing = true,
EnableDefaultFiles = false,
FileSystem = new PhysicalFileSystem(".\\public")
});
app.UseStageMarker(PipelineStage.Authenticate);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
</system.web>
<system.webServer>
<handlers>
<remove name="StaticFile"/>
</handlers>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment