Question : regarding how the application base href affects the form action URL in Angular html component #231

Closed
opened 2025-08-09 17:15:30 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @jagmagh on 1/12/2018

I am building an ASP.net core 1.x + Angular 4.x app using the JavascriptServices Angular Template

In our environment, we have the base href set to / for Development and xxx for Production deployments

To do this, we have a conditional code in_Layout.cshtmlthat reads

@if (hostingEnv.EnvironmentName == "Development") {
            @:<base href="/" />
        } else {
            @:<base href="/xxx/" />
        }

In one of the Angular component templates, I have the following form

<form ngNoForm id="logoutForm" action="/Account/Logout" method="post">
                            <button type="submit" form="logoutForm">
                                <span class="fa fa-sign-out"></span>
                                &nbsp;Log Out
                            </button>
                        </form>

When I dotnet publish my project, in the main-client,js, the action property would be updated as follows

<form ngNoForm id="logoutForm" action="/xxx/Account/Logout" method="post">

My understanding is that is one of the changes expected to be done as part of the webpack build and it was working as expected till our last build on last Sunday.

However, without any code changes made to any of these files files (verified via git) since Sunday, i find my builds today does not make this URL change anymore so my code remains as

<form ngNoForm id="logoutForm" action="/Account/Logout" method="post">

which causes a failure on deployment. The only change made is that a different build server is being used for generating the build.

The command used to generate the build is dotnet publish -c Release -o X:\somefolder

My understanding of the entire webpack build is limited and if someone can shed some light on this issue or atleast give me some pointers as to where to look, it would be much appreciated. Thanks.

*Originally created by @jagmagh on 1/12/2018* I am building an ASP.net core 1.x + Angular 4.x app using the JavascriptServices Angular Template In our environment, we have the `base href` set to `/` for Development and `xxx` for Production deployments To do this, we have a conditional code in` _Layout.cshtml `that reads ``` @if (hostingEnv.EnvironmentName == "Development") { @:<base href="/" /> } else { @:<base href="/xxx/" /> } ``` In one of the Angular component templates, I have the following form ``` <form ngNoForm id="logoutForm" action="/Account/Logout" method="post"> <button type="submit" form="logoutForm"> <span class="fa fa-sign-out"></span> &nbsp;Log Out </button> </form> ``` When I `dotnet publish` my project, in the `main-client,js`, the action property would be updated as follows ```<form ngNoForm id="logoutForm" action="/xxx/Account/Logout" method="post">``` My understanding is that is one of the changes expected to be done as part of the webpack build and it was working as expected till our last build on last Sunday. However, without any code changes made to any of these files files (verified via git) since Sunday, i find my builds today does not make this URL change anymore so my code remains as ```<form ngNoForm id="logoutForm" action="/Account/Logout" method="post">``` which causes a failure on deployment. The only change made is that a different build server is being used for generating the build. The command used to generate the build is `dotnet publish -c Release -o X:\somefolder` My understanding of the entire webpack build is limited and if someone can shed some light on this issue or atleast give me some pointers as to where to look, it would be much appreciated. Thanks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#231
No description provided.