Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Angular under Virtual Directory on IIS

Tags:

iis

angular

iis-8

This question is related to Angular2+ (not AngularJS)

We are trying to host our angular site under a virtual directory under a website on IIS.

We have a Website Called Development that points to: C:\inetpub\wwwroot\Development. In this folder we have another folder called Web. This Web folder holds the angular site code (built with ng build --base-href "/Web" --deploy-url "/Web"

When we navigate to http://server/Web, everything seems to be loading fine, except for the 0.chuck.js file. For some reason this file is being requested as:

http://server/Web0.chuck.jsenter image description here

It seems like the "/" is missing before the 0, but I'm not sure where this setting could be handled.

Any ideas?

like image 357
Newteq Developer Avatar asked May 12 '17 09:05

Newteq Developer


People also ask

Can Angular run on IIS?

The Angular Router is a fantastic module for Single Page Apps. However, to deploy it in a Production scenario you will typically need to do some configuration to make it work. This article details the steps necessary to deploy an Angular Router application anywhere on Internet Information Services (IIS).

Can Angular run on shared hosting?

import { LocationStrategy, PathLocationStrategy } from '@angular/common'; Now execute ng build --prod once more and upload the new distribution files to your shared server — everything should now work! That is all you need to begin working with Angular on your very own shared hosting server.


1 Answers

The url change is handled by webpack. This is controlled by the --deploy-url.

Running the following fixes it:

ng build --base-href "/Web" --deploy-url "/Web/"
like image 187
Newteq Developer Avatar answered Oct 05 '22 02:10

Newteq Developer