// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { //loggerFactory.AddConsole(); //if (env.IsDevelopment()) //{ // app.UseDeveloperExceptionPage(); //} //app.Run(async (context) => //{ // await context.Response.WriteAsync("Hello World!"); //}); var phpOptions = new PhpRequestOptions { ScriptAssembliesName = new[] { "Peachpie.PDO.Test.Website" } }; app.UsePhp(phpOptions); app.UseDefaultFiles(); app.UseStaticFiles(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } if (env.IsStaging() || env.IsProduction()) { app.UseHsts(); } app.UseHttpsRedirection(); app.UseSession(); // Use re-write to redirect source to wwwroot folder for php script files // UsePhp cannot translate the base path to a sub folder of the project file. var rewriteOptions = new RewriteOptions() //.AddRewrite(@"^.*?/[^/.]*(?:/([#?].*))?$", "wwwroot/$0", skipRemainingRules: true) // Directory //.AddRewrite(@"^(?:[^\?]+)(?:\.php)(?:.*)", "wwwroot/$0", skipRemainingRules: true); // IsFile = .php .Add(new PhpRewriteRule(".php", "wwwroot", skipRemainingRules: true)); // .Add((context) => { // var request = context.HttpContext.Request; // context.Result = RuleResult.SkipRemainingRules; // request.Path = request.Path; // request.QueryString = new QueryString(""); // }); app.UseRewriter(rewriteOptions); // app.Run(context => context.Response.WriteAsync( // $"Rewritten or Redirected Url: " + // $"{context.Request.Path + context.Request.QueryString}")); var phpOptions = new PhpRequestOptions(scriptAssemblyName: "Website"); phpOptions.RootPath = Path.Combine(AppContext.BaseDirectory); app.UsePhp(phpOptions); app.UseDefaultFiles(); Console.WriteLine($"Content Root Path: {Path.Combine(AppContext.BaseDirectory, "wwwroot")}"); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider( Path.Combine(AppContext.BaseDirectory, "wwwroot")), //ContentTypeProvider = MimeTypes.GetKnownFileTypes() ContentTypeProvider = new FileExtensionContentTypeProvider() }); app.UseCookiePolicy(); }
/// <summary> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app">The application.</param> public void Configure(IApplicationBuilder app) { var phpRequestOptions = new PhpRequestOptions { ScriptAssembliesName = new[] { //Name of the compiled php assembly, if not "website" "website" } }; app.UsePhp(phpRequestOptions); app.UseDefaultFiles(); app.UseStaticFiles(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } var phpOptions = new PhpRequestOptions(scriptAssemblyName: "Peachpie.PDO.Test.Website"); app.UsePhp(phpOptions); app.UseDefaultFiles(); app.UseStaticFiles(); }