Home > Software design >  Error while hosting angular 13 application in IIS
Error while hosting angular 13 application in IIS

Time:09-28

enter image description here

I created a angular 13 application using ng new Application name served the application using ng serve it works fine. I built the same application and tried hosting it in IIS by creating a new website. But it is not executing in server. I have proper web.config file too. What could be the issue

CodePudding user response:

I had selected * (in file type) and mapped to a python.exe in handler mapping in IIS (whose name was flaskhandler) for this site. As a result any application hosted in this site was being executed by python. On removing the mapping issue was resolved.

CodePudding user response:

Download and Install Httpplatformhandler on IIS using Windows Platform Installer. Or download from this link.

You can refer to the following steps to host a Flask web application using Httpplatformhandler.

For Flask physical path is a path to app.py of your application. Add web.config where your flask is defined.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="httpplatformhandler" path="*" verb="*" > modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
        </handlers>
        <httpPlatform startupTimeLimit="10" startupRetryCount="10" stdoutLogEnabled="true" processPath="C:\Users\user\AppData\Local\Programs\Python\Python36\python.exe" arguments="app.py">
            <environmentVariables>
                <environmentVariable name="foo" value="bar"/>
            </environmentVariables>
        </httpPlatform>
    </system.webServer>
</configuration>

In the above web.config, httpPlaform is handling the Python process. ProcessPath is a physical path to python executable. Just like you provide python path in a windows environment variable. To access the python executable. Here you have to provide python.exe in processPath.

Arguments are the same argument you pass running any python web application. For eg. python app.py -p 5005 where app.py to port number all are arguments. In the above application, app.py is passed to run flask application.

Add Permission to Flask Application and Python folder where your executable is present.

  1. Open folder properties.

  2. In Security click on Edit then click on Add

  3. Enter object name as IIS AppPool\<yourappname>

  4. Click on the check name if its present click ok and allow permissions you wanted to give then apply it.

Run your application

For more information, please refer to this tutorial.

  • Related