Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0-rc2-final, base element href attribute hard coded? #163

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

Originally created by @rglos on 2/19/2018

I'm trying to get my feet wet using Angular and ASP.NET Core.

It appears that when using the new Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0-rc2-final template to create a project, there are no longer any server side views (no Views\Home|Shared\*.cshtml files) and therefore the <base href="~/" /> that we had in the previous template is now hard coded in the ClientApp\src\index.html file?

In my scenario, I was attempting to deploy the application to my local Windows 10 IIS server to demo some features to my peers, e.g. something like http://localmachinename/check-this-out, by deploying this to an Application under Default Web Site. When you attempt to browse that app, it just shows Loading... because it throws 404 not found attempting to load all the *.js and *.css and it can't find them because the base element is <base href="/">. Of course if I change that value, F5 doesn't work. So is this something we should be changing at deployment time via VSTS Release Management or am I doing it wrong?

To reproduce:

  1. dotnet new -o my-new-app
  2. Note that F5 works
  3. Right click project, publish, using Web Deploy, server: localmachinename, site name: Default Web Site/my-new-app, Destination URL: http://localmachinename/my-new-app
  4. Note that when it's done deploying and launches the site, you just see 'Loading...' - open the browser debug tools to see the issue that it can't find resources (404 errors)

If you do this with the previous template via File -> New Project, ASP.NET Core Web App, choose Angular, you get the razor? views which can generate a proper base element path at run time.

*Originally created by @rglos on 2/19/2018* I'm trying to get my feet wet using Angular and ASP.NET Core. It appears that when using the new `Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0-rc2-final` template to create a project, there are no longer any server side views (no `Views\Home|Shared\*.cshtml` files) and therefore the `<base href="~/" />` that we had in the previous template is now hard coded in the `ClientApp\src\index.html` file? In my scenario, I was attempting to deploy the application to my local Windows 10 IIS server to demo some features to my peers, e.g. something like `http://localmachinename/check-this-out`, by deploying this to an Application under `Default Web Site`. When you attempt to browse that app, it just shows `Loading...` because it throws 404 not found attempting to load all the *.js and *.css and it can't find them because the base element is `<base href="/">`. Of course if I change that value, F5 doesn't work. So is this something we should be changing at deployment time via VSTS Release Management or am I doing it wrong? To reproduce: 1. dotnet new -o my-new-app 2. Note that F5 works 3. Right click project, publish, using Web Deploy, server: localmachinename, site name: Default Web Site/my-new-app, Destination URL: http://localmachinename/my-new-app 4. Note that when it's done deploying and launches the site, you just see 'Loading...' - open the browser debug tools to see the issue that it can't find resources (404 errors) If you do this with the previous template via File -> New Project, ASP.NET Core Web App, choose Angular, you get the razor? views which can generate a proper base element path at run time.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#163
No description provided.