Last post Nov 08, 2018 04:24 PM by comicrage
Nov 07, 2018 02:49 PM|comicrage|LINK
I have an angular project and the home page is mostly HTML. When I type "npm start", all the images successfully loads. When I typed the "npg build --base-href "/MyProject/" --prod, the home page is blank when I create its own website with a unique port.
When I add website under Default Web Site, the home page loads but I see the error
Failed to load resource: the server responded with a status of 404 (Not Found)
for each image it is trying to load
In the HTML code, it have the following
<div> <div><p> <img
I tried added the tilda like <img alt=""
/> but it still does not work.
Finally, I loaded again with Chrome and hit F12. I clicked on the 404 error and see the list of images associated with the home page. On an image that has problems loading, I see the page as
The page is incorrect and will not find the image .
I figure if I can get the images to load under Default WebSite, then it will also load in its own website and portnumber. I am hoping the image location issue fix will fix the loading in IIS.
I also copied/pasted the image file to the root folder where it is located in wwwroot/MyProject/image123.png. That actually loads the file when I changed the following
<div> <div><p> <img
However, when I moved the image file to wwwroot/MyProject/assets/image123.png with the following
it does not load the image. I tried change to the following
<img alt="" src="~assets/img/image123.png" />
It does not load the image file. I am not sure why it can't load the image file when it is located inside the subfolders.
Nov 08, 2018 08:04 AM|Fei Han - MSFT|LINK
When I typed the "npg build --base-href "/MyProject/" --prod
According to you description, we can find that you compiled your application into an output directory by using ng build, and you set base tag href to
You could go dist folder and modify the code snippet of displaying image to below.
<img width="300" alt="Angular Logo" src="./assets/img/image123.PNG">
And then you can setup your site with compiled package on IIS server.
Nov 08, 2018 04:24 PM|comicrage|LINK
Thanks Fei Han