1

I'm trying to integrate my Angular 4 app into asp.net mvc core project. And I'd like to have Angular app available within my Core MVC project with this Url - mydomain.com/ngx.

Here's how I do it now (and it doesn't work):

I build Angular app with angular-cli and use ng build ... --base-href /ngx (notice the slash). Then I copy everything from dist folder (where the build is placed by CLI) and copy it into wwwroot/ngx folder into my Core MVC project. But when I open localhost/ngx/index.html I get 404 errors for main.bundle.js and other js files. I checked the requests and for some reason it tries to get it as localhost://main.bundle.js - why from root?

now, if I build it with --base-href ngx (no slash) and open the site, it gets redirected to /ngx/ngx (doubles the ngx). so... wtf? :)

Core MVC routing doesn't have anything special, I haven't touched that part.

So how can I make it work as localhost/ngx ASP.NET Core MVC project?

2
  • Works fine here with ng build --base-href /ngx/ --output-path dist/ngx, running http-server from the dist directory, and going to http://localhost:8080/ngx/index.html. Commented Apr 17, 2017 at 13:53
  • Oh, man, thanks!!! Do you want me to add it as an answer or you'll do it yourself? Commented Apr 17, 2017 at 13:56

1 Answer 1

4

Works fine here with

ng build --base-href /ngx/ --output-path dist/ngx, 

running http-server from the dist directory, and going to http://localhost:8080/ngx/index.html

Sign up to request clarification or add additional context in comments.

1 Comment

I just found out that whatever you have in assets gets not found because it tries to get them from root (/assets/whatever) but it should try to get them from /ngx/assets/whatever. :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.