public static IAppBuilder UseHtml5Mode(this IAppBuilder app, string rootPath, string entryPath) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (rootPath == null) { throw new ArgumentNullException(nameof(rootPath)); } if (entryPath == null) { throw new ArgumentNullException(nameof(entryPath)); } var options = new Html5ModeOptions { EntryPath = new PathString(entryPath), FileServerOptions = new FileServerOptions() { EnableDirectoryBrowsing = false, FileSystem = new PhysicalFileSystem(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, rootPath)) } }; app.UseDefaultFiles(options.FileServerOptions.DefaultFilesOptions); return(app.Use(new Func <AppFunc, AppFunc>(next => new Html5ModeMiddleware(next, options).Invoke))); }
public Html5ModeMiddleware(AppFunc next, Html5ModeOptions options) { if (next == null) { throw new ArgumentNullException(nameof(next)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } m_Options = options; m_InnerMiddleware = new StaticFileMiddleware(next, options.FileServerOptions.StaticFileOptions); m_EntryPointAwareInnerMiddleware = new StaticFileMiddleware((environment) => { var context = new OwinContext(environment); context.Request.Path = m_Options.EntryPath; return(m_InnerMiddleware.Invoke(environment)); }, options.FileServerOptions.StaticFileOptions); }