locked
Angular 5 project publish to IIS 10 405 error RRS feed

  • Question

  • User-1591111454 posted

    Error message when a post request in Postman a angular 5 website that is hosted on a server that is running Internet Information Services 10.0: "HTTP Error 405.0 - Method not allowed" but when get request in Postman this web site "200 ok"

    Wednesday, September 5, 2018 2:26 PM

Answers

  • User283571144 posted

    Hi alicanuslu,

    In my opinion, this is the right error.

    If you use ng-serve to run your angular page, it will return error as below:

    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8">
            <title>Error</title>
        </head>
        <body>
            <pre>Cannot POST /</pre>
        </body>
    </html>

    Since Angular is running inside of the browser when the POST requests are coming to the server. Usually your server just rewrites all (or almost all) incoming requests to your index.html and Angular by parsing the URL knows which state to show.

    In other words, your POST data is received on your server but not passed through. You can catch it at the moment of rewriting and pass the data in some way (print it inside of HTML, set as cookies, etc) to your Angular app.

    If I was choosing the way to pass the data I would prefer to just store the POST data in a database under some ID and then redirect the browser to the Angular app with a get parameter telling to pick the data under the specified ID.

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 6, 2018 5:44 AM

All replies

  • User283571144 posted

    Hi alicanuslu,

    In my opinion, this is the right error.

    If you use ng-serve to run your angular page, it will return error as below:

    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8">
            <title>Error</title>
        </head>
        <body>
            <pre>Cannot POST /</pre>
        </body>
    </html>

    Since Angular is running inside of the browser when the POST requests are coming to the server. Usually your server just rewrites all (or almost all) incoming requests to your index.html and Angular by parsing the URL knows which state to show.

    In other words, your POST data is received on your server but not passed through. You can catch it at the moment of rewriting and pass the data in some way (print it inside of HTML, set as cookies, etc) to your Angular app.

    If I was choosing the way to pass the data I would prefer to just store the POST data in a database under some ID and then redirect the browser to the Angular app with a get parameter telling to pick the data under the specified ID.

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 6, 2018 5:44 AM
  • User-1591111454 posted

    Hi Brando,

    Thanks for reply ,

    Best Regards.

    Thursday, September 6, 2018 7:03 AM