Exemplo n.º 1
0
        public static void UseStaticFiles(this IAppBuilder app, string directory)
        {
            var configuration = new StaticFilesConfiguration()
            {
                Directory = directory
            };

            UseStaticFiles(app, configuration);
        }
Exemplo n.º 2
0
        public void Configuration(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif
            var configuration = new StaticFilesConfiguration("htdocs");
            configuration.AddIgnoredExtension(".ts");

            app.UseStaticFiles(configuration);
        }
        public StaticFilesMiddleware(OwinMiddleware next, StaticFilesConfiguration configuration) : base(next)
        {
            Debug.Assert(configuration != null, "_configuration != null");

            Configuration = configuration;
            
            // Finds the webdirectory being local
            var path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            WebDirectory = Path.Combine(path, Configuration.Directory);
            
            if (!Directory.Exists(WebDirectory))
            {
                throw new InvalidOperationException("Path for static file directory does not exist: " +
                                                    configuration.Directory);
            }
        }
Exemplo n.º 4
0
        public void Configuration(IAppBuilder app)
        {
            #if DEBUG
            app.UseErrorPage();
            #endif

            var directory = "htdocs";
            #if DEBUG
            if (Directory.Exists("..\\..\\htdocs"))
            {
                directory = "..\\..\\htdocs";
            }

            if (Directory.Exists("..\\..\\..\\htdocs"))
            {
                directory = "..\\..\\..\\htdocs";
            }
            #endif

            // Do the full load of all assemblies
            Integration.DotNet.LoadingHelper.LoadAllAssembliesFromCurrentDirectory();
            Integration.DotNet.LoadingHelper.LoadAllReferencedAssemblies();
            Integration.DotNet.LoadingHelper.LoadAssembliesFromFolder("plugins");

            // Initializing of the WebAPI, needs to be called after the DatenMeister is initialized
            var httpConfiguration = new HttpConfiguration();
            httpConfiguration.MapHttpAttributeRoutes();

            _serverInjection = CreateKernel(app);

            var builder = new ContainerBuilder();
            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            builder.Update(_serverInjection);

            httpConfiguration.DependencyResolver = new AutofacWebApiDependencyResolver(_serverInjection);

            _lifetimeScope = _serverInjection.BeginLifetimeScope("DatenMeister Webapplication");

            app.UseAutofacMiddleware(_lifetimeScope);

            var configuration = new StaticFilesConfiguration(directory);
            app.UseStaticFiles(configuration);
            app.UseAutofacWebApi(httpConfiguration);
            app.UseWebApi(httpConfiguration);
        }
Exemplo n.º 5
0
        public void Configuration(IAppBuilder app)
        {
            const string directory = "htdocs";

            var configuration = new StaticFilesConfiguration(directory);
            //configuration.AddIgnoredExtension(".ts");
            app.UseStaticFiles(configuration);

            // Initializes the DatenMeister
            //DataProvider.TheOne.Init();
            var dataPath = Path.Combine(HttpRuntime.AppDomainAppPath, "App_Data/plz.csv");
            using (var stream = new FileStream(dataPath, FileMode.Open))
            {
                DataProvider.TheOne.LoadZipCodes(stream);
            }

            // ReSharper disable once ObjectCreationAsStatement
            new ZipController();

            // We have a stage marker here, so the static files are handled
            app.UseStageMarker(PipelineStage.MapHandler);

            // Initializing of the WebAPI, needs to be called after the DatenMeister is initialized
            var httpConfiguration = new HttpConfiguration();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
            app.UseWebApi(httpConfiguration);

            app.Use((context, next) =>
            {
                context.Response.StatusCode = 404;
                context.Response.ContentType = "text/plain";
                return context.Response.WriteAsync("UNKNOWN");
            });
        }
Exemplo n.º 6
0
        public static void UseStaticFiles(this IAppBuilder app, StaticFilesConfiguration configuration)
        {
            Debug.Assert(configuration != null, "configuration != null");

            app.Use(typeof(StaticFilesMiddleware), configuration);
        }