本文整理汇总了C#中IAppBuilder.UseDirectoryBrowser方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.UseDirectoryBrowser方法的具体用法?C# IAppBuilder.UseDirectoryBrowser怎么用?C# IAppBuilder.UseDirectoryBrowser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAppBuilder
的用法示例。
在下文中一共展示了IAppBuilder.UseDirectoryBrowser方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configuration
public void Configuration(IAppBuilder app)
{
#if DEBUG
app.UseErrorPage();
#endif
// Remap '/' to '.\defaults\'.
// Turns on static files and default files.
app.UseFileServer(new FileServerOptions()
{
RequestPath = PathString.Empty,
FileSystem = new PhysicalFileSystem(@".\defaults"),
});
// Only serve files requested by name.
app.UseStaticFiles("/files");
// Turns on static files, directory browsing, and default files.
app.UseFileServer(new FileServerOptions()
{
RequestPath = new PathString("/public"),
EnableDirectoryBrowsing = true,
});
// Browse the root of your application (but do not serve the files).
// NOTE: Avoid serving static files from the root of your application or bin folder,
// it allows people to download your application binaries, config files, etc..
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
{
RequestPath = new PathString("/src"),
FileSystem = new PhysicalFileSystem(@""),
});
// Anything not handled will land at the welcome page.
app.UseWelcomePage();
}
示例2: Configuration
public void Configuration(IAppBuilder app)
{
/* // Note: Enable only for debugging. This slows down the perf tests.
app.Use((context, next) =>
{
var req = context.Request;
context.TraceOutput.WriteLine("{0} {1}{2} {3}", req.Method, req.PathBase, req.Path, req.QueryString);
return next();
});*/
app.UseErrorPage(new ErrorPageOptions { SourceCodeLineCount = 20 });
// app.Use(typeof(AutoTuneMiddleware), app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]);
app.UseSendFileFallback();
app.Use<CanonicalRequestPatterns>();
app.UseStaticFiles(new StaticFileOptions()
{
RequestPath = new PathString("/static"),
FileSystem = new PhysicalFileSystem("public")
});
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
{
RequestPath = new PathString("/static"),
FileSystem = new PhysicalFileSystem("public")
});
app.UseStageMarker(PipelineStage.MapHandler);
FileServerOptions options = new FileServerOptions();
options.EnableDirectoryBrowsing = true;
options.StaticFileOptions.ServeUnknownFileTypes = true;
app.UseWelcomePage("/Welcome");
}
示例3: Configuration
public void Configuration(IAppBuilder app)
{
var fileSystem = new PhysicalFileSystem(this.serverConfig.RootFolder);
if (this.serverConfig.AllowDirectoryBrowsing)
{
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
{
FileSystem = fileSystem
});
}
app.UseStaticFiles(new StaticFileOptions()
{
FileSystem = fileSystem,
ServeUnknownFileTypes = true
});
}
示例4: ConfigureUserSpace
private void ConfigureUserSpace(IAppBuilder appBuilder)
{
var appConfig = ObjectFactory.GetProvider<IAppConfigProvider>().AppConfig;
var fileSystem = new PhysicalFileSystem(appConfig.WebRoot);
appBuilder.Use(typeof(RedirectUrl));
appBuilder.UseDirectoryBrowser(new DirectoryBrowserOptions
{
RequestPath = new PathString(""),
FileSystem = fileSystem
});
appBuilder.UseStaticFiles(new StaticFileOptions
{
RequestPath = new PathString(""),
FileSystem = fileSystem,
ServeUnknownFileTypes = true
});
}
示例5: EmbeddedDirectoryBrowserFileSystemConfiguration
public void EmbeddedDirectoryBrowserFileSystemConfiguration(IAppBuilder app)
{
app.UseDirectoryBrowser(new DirectoryBrowserOptions() { FileSystem = new EmbeddedResourceFileSystem(Assembly.GetExecutingAssembly().GetName().Name) });
}
示例6: ConfigureStaticFileServer
private static void ConfigureStaticFileServer(IAppBuilder app)
{
#if DEBUG
app.UseErrorPage();
#endif
// Remap '/' to '.\defaults\'.
// Turns on static files and default files.
var integrityUiPath = @"..\..\..\Integrity";
string currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
integrityUiPath = Path.Combine(currentDirectory, integrityUiPath);
integrityUiPath = Path.GetFullPath((new Uri(integrityUiPath)).LocalPath);
if (!Directory.Exists(integrityUiPath))
{
throw new Exception(String.Format("Directory {0} does not exist", integrityUiPath));
}
var options = new FileServerOptions()
{
RequestPath = PathString.Empty,
FileSystem = new PhysicalFileSystem(integrityUiPath)
};
//options.StaticFileOptions.ContentTypeProvider = new CustomContentTypeProvider();
app.UseFileServer(options);
//var hubConfiguration = new HubConfiguration();
//hubConfiguration.EnableDetailedErrors = true;
//app.MapSignalR(hubConfiguration);
// Browse the root of your application (but do not serve the files).
// NOTE: Avoid serving static files from the root of your application or bin folder,
// it allows people to download your application binaries, config files, etc..
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
{
RequestPath = new PathString("/src"),
FileSystem = new PhysicalFileSystem(@""),
});
}
示例7: DirectoryBrowser
public void DirectoryBrowser(IAppBuilder app)
{
app.Use((context, next) => { context.Response.Headers["PassedThroughOWIN"] = "True"; return next(); });
app.UseDirectoryBrowser();
app.Run(context => { context.Response.StatusCode = 402; return context.Response.WriteAsync("Fell Through"); });
}
示例8: DirectoryBrowserCustomFormatterConfiguration
public void DirectoryBrowserCustomFormatterConfiguration(IAppBuilder app)
{
app.UseDirectoryBrowser(new DirectoryBrowserOptions() { Formatter = new MyDirectoryInfoFormatter() });
}
示例9: Configuration
public void Configuration(IAppBuilder builder)
{
builder.UseDirectoryBrowser(@"c:\");
}
示例10: CustomFileSystemConfiguration
public void CustomFileSystemConfiguration(IAppBuilder app)
{
app.UseDirectoryBrowser(new DirectoryBrowserOptions() { FileSystem = new MyFileSystem() });
}
示例11: DirectoryMiddlewareMappedToDifferentDirectoryConfiguration
public void DirectoryMiddlewareMappedToDifferentDirectoryConfiguration(IAppBuilder app)
{
app.UseDirectoryBrowser(new DirectoryBrowserOptions() { FileSystem = new PhysicalFileSystem(@"RequirementFiles\Dir1") });
}
示例12: DirectoryBrowserDefaultsConfiguration
public void DirectoryBrowserDefaultsConfiguration(IAppBuilder app)
{
app.UseDirectoryBrowser();
}
示例13: DirectoryCustomRequestPathToPhysicalPathMappingConfiguration
public void DirectoryCustomRequestPathToPhysicalPathMappingConfiguration(IAppBuilder app)
{
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
{
RequestPath = new PathString("/customrequestPath"),
FileSystem = new PhysicalFileSystem(@"RequirementFiles\Dir1")
});
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
{
RequestPath = new PathString("/customrequestFullPath"),
FileSystem = new PhysicalFileSystem(Path.Combine(Environment.CurrentDirectory, @"RequirementFiles\Dir2"))
});
var localAbsolutePath = Path.Combine(Environment.CurrentDirectory, @"RequirementFiles\Dir3");
var uncPath = Path.Combine("\\\\", Environment.MachineName, localAbsolutePath.Replace(':', '$'));
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
{
RequestPath = new PathString("/customrequestUNCPath"),
FileSystem = new PhysicalFileSystem(uncPath)
});
}