-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Is it possible to host angular-cli generated app in an ASP.NET MVC project? #2960
Comments
I too am using the CLI for an intranet application, and I was wondering, have you considered trying out node-activedirectory to support Windows Auth natively? It works great for our purposes, and you made no mention of ASP.NET being required by the spec to make the Auth requests, just that that is how you were going to do it. |
@gelliott181 - Thanks for the heads up on that package, I wasn't aware it existed! It looks promising and if we can pull one more dependency out of the project all the better! I'll post back to this issue with my results. |
I can't comment on the ASP.NET MCV bit myself but will leave it open for people to comment. Regarding app structure, everything you can configure is in |
Here is my solution:
It works perfectly for my ASP.net MVC 5 project. |
PR created for publicPath support |
it is possible to do so. I am working on doing just that, migrating a legacy web site to host an Angular2 SPA inside an ASPX page. What I actually did was to generate a Visual Studio Typescript project and folder, and used ng init to generate the angular-cli structure. I created a gulpfile.js with gulp tasks to handle the copying of the dist folder, assets and legacy javascript files to a predefined folder in the Web Site project structure. The ASPX page sources the script bundles and the legacy javascript files copied to the Web Site, and bootstraps the angular2 app. One gotcha you have to consider is the difference in bundle names between dev and prod builds. We solved that by removing the hash code from the bundle files in the gulp task that copies the bundle files to the web site folder. We have our own cache busting version mechanism in place already, so I just reused that. In the VS typescript project, you don't really want VS to compile your typescript, since it should rely on ng build instead. You can set up a Pre-Build event to set up the right environment (Debug or Release), call ng build (with --prod --aot for Release mode), and a Post-Build event to call the gulp task that will copy everything over to the Web Site folder. Put the typescript project in the same solution as the Web Site, so when the entire solution is built, the typescript project can be built before the Web Site project, and it will work with an automated build system. There are a few hoops to jump through, given that we can't convert our legacy system over to .NET Core MVC in the first release, but the workflow is reasonable enough for us. Good luck |
I have found kind of solution it is not 100% perfect but will do the job.
credits to jonCubed |
…ngular#3285) Add publicPath option for webpack. User can specify publicPath via `--deploy-url` / `-d` from command line or add `deployUrl` to `angular-cli.json`. It can solve following issues: Change the public URL address of the output files (different from baseUrl). Manipulate the request url for chunk js files. It is very helpful to solve resources url and route lazying load issues for those applications which have different static files paths such as ASP.NET MVC. Fixes angular#3136 Fixes angular#2960 Fixes angular#2276 Fixes angular#2241 Fixes angular#3344
I wrote up a blog post on using Angular CLI inside of a Visual Studio MVC Web application similar to what @vcdassen-home1 and @changLiuUNSW described. All the relevant commands are included, plus a git repo with the final result and commits for each step along the way that you can review. http://candordeveloper.com/2017/04/12/how-to-use-angular-cli-with-visual-studio-2017/ A better integration between CLI and Visual Studio would be nice, but this works. |
@michael-lang Great tutorial, but a little bit confusing comparing to your Repo |
I would like to refresh the subject, but what about when you have MVC Areas in the application. I've managed to do that, but I have problems for example when loading fonts from prime ng. The fonts are requested (at least network says so) from http://localhost/MyArea/font-name.woff etc |
I have a series of 3 new demo projects showing integrations between asp.net core and angular. The steps to build each option are on the readme page of the following demo repo: https://github.com/NexulAcademy/demo-aspnet-angular |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
OS?
Versions.
Repro steps.
(I'm going this route because we are building an intranet application and the users want (er... require) to take advantage of single sign on (ie - pass through Windows Authentication).
The text was updated successfully, but these errors were encountered: