Esempio n. 1
0
        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.");
        }
Esempio n. 2
0
 public SpaMiddleware(RequestDelegate next, SpaMiddlewareOptions options, IHostingEnvironment env)
 {
     _next    = next;
     _options = SetupPath(env, options);
 }