Home > Mobile >  How to exclude a particular folder from ASP.NET 6 on IIS and allow it to process by PHP handlers?
How to exclude a particular folder from ASP.NET 6 on IIS and allow it to process by PHP handlers?

Time:02-03

I can deploy an ASP.NET 6 web app to IIS on Windows 2019 Server. All is working.

The default web.config is generated and exist in the root:

<system.webServer>
<handlers>
  <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\TestWebApp.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>

Question

I would like to have a /blog folder and I would like deploy a PHP application there. How can I explain to IIS to not pass those request to the AspNetCoreModuleV2 handler, instead pass those requests to the PHP handler? (url rewrite module is already installed)

CodePudding user response:

I've ended using the <location...> element and removing the handler from the blog path.

The key is removing the handler for the blog subfolder, which can be done with the <remove>. It is possible either with using the <location...> element, or as an alternative placing a web.config to the blog subfolder, and removing the handler there.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath=".\TestWebApp.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
  <location path="blog">
    <system.webServer>
      <handlers>
        <remove name="aspNetCore" />
      </handlers>
    </system.webServer>
  </location>
</configuration>

CodePudding user response:

You can create a Virtual Application under your webapp site.

The official documentation has only one paragraph describing this Virtual Application. The answers in the following posts are very detailed and will help you.

Using ServerManager to create Application within Application

My Test Result for you

This test in the azure web app, it's same as IIS.

How to deploy a Flask React application to Azure Web Service

  •  Tags:  
  • Related