private static SpaMiddlewareOptions SetupPath(IHostingEnvironment env, SpaMiddlewareOptions options) { if (!string.IsNullOrWhiteSpace(options.PathToIndex)) { if (File.Exists(options.PathToIndex)) { return(options); } } var indexFile = env.WebRootFileProvider .GetDirectoryContents("") .FirstOrDefault(x => x.Name.ToLower().Contains("index") && x.Name.ToLower().EndsWith("html")); if (indexFile != null) { return(new SpaMiddlewareOptions(indexFile.PhysicalPath, options.SpecialRoutes)); } throw new ArgumentException("PathToIndex was incorrect."); }
public SpaMiddleware(RequestDelegate next, SpaMiddlewareOptions options, IHostingEnvironment env) { _next = next; _options = SetupPath(env, options); }