Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Execute PHP as a static file in Core

$
0
0

I have a dot net core 2.0 web application (say App1.com) which also supports static files. That is, in the root directory, outside wwwroot, I have an updater folder, which holds some files (exe and a PHP file) to be used by a separate application, which would call the php file like www.App1.com\updater\file.php

I added following to my startup:

app.UseStaticFiles(new StaticFileOptions()
{
    ServeUnknownFileTypes = true,
    FileProvider = new PhysicalFileProvider(
       Path.Combine(Directory.GetCurrentDirectory(), @"updater")),
    RequestPath = new PathString("/updater1")
});

So now, this allows the app to access the static files, but the issue is that the PHP file is getting served instead of getting executed. PHP is installed on the server and works. I have tried following with no help:

  1. Check phpInfo() in PHP manager was returning 404 for App1 site, so I went to Handler mappings, and in the ordered list, I moved the PHP55_via_FastCGI above aspnetcore, but then the php file gives me a 404, rest of the files are served just fine.
  2. So next I tried to move the php just for the updater folder by adding a web config file for the folder, but that did not do anything either.

So, the question is when serving static files in an aspnetcore web app, if the requested file is a php file, how do i get it executed?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>