Example #1
0
        /// <summary>
        /// Update the standing data and save to file
        /// </summary>
        /// <param name="configModel"></param>
        public static void SaveStandingData(ImportConfigModel configModel)
        {
            if (!string.IsNullOrEmpty(configModel.FileName301))
            {
                StandingData.FileName301 = configModel.FileName301.RemoveBeginningAndTrailingSlashes();
            }
            if (!string.IsNullOrEmpty(configModel.HtmlFile301))
            {
                StandingData.HtmlFile301 = configModel.HtmlFile301.RemoveBeginningAndTrailingSlashes();
            }
            if (!string.IsNullOrEmpty(configModel.HtmlRootFolder))
            {
                StandingData.HtmlRootFolder = configModel.HtmlRootFolder.RemoveBeginningAndTrailingSlashes();
            }
            if (!string.IsNullOrEmpty(configModel.TemplatesFolder))
            {
                StandingData.TemplatesFolder = configModel.TemplatesFolder.RemoveBeginningAndTrailingSlashes();
            }
            if (!string.IsNullOrEmpty(configModel.UmbracoRootFolderUrl))
            {
                StandingData.UmbracoRootFolderUrl = configModel.UmbracoRootFolderUrl.RemoveBeginningAndTrailingSlashes();
            }

            ContentUpdater.CreateFile(StandingData.ConfigFile, JsonConvert.SerializeObject(configModel, Formatting.Indented));
        }
        /// <summary>
        /// Ignore all routing from files, use HtmlRootFolder
        /// </summary>
        /// <param name="app"></param>
        private void ConfigureMiddleware(IAppBuilder app)
        {
            // create the html root folder if it doesn't exist
            var  folderLocation = ContentUpdater.GetFolderLocation("");
            bool exists         = Directory.Exists(folderLocation);

            if (!exists)
            {
                Directory.CreateDirectory(folderLocation);
            }


            var physicalFileSystem = new PhysicalFileSystem(@"./" + StandingData.HtmlRootFolder);

            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem         = physicalFileSystem
            };

            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames    = new[]
            {
                "index.html"
            };

            app.UseFileServer(options);
        }