Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include js file without knowing proper name in Asp.Net Core

<script src="~/angular/runtime*"></script>
<script src="~/angular/polyfills*"></script>
<script src="~/angular/vendor*"></script>
<script src="~/angular/main*"></script>

enter image description here

I want to add these scripts in my Layout page

like image 595
Uxmaan Ali Avatar asked Dec 18 '18 10:12

Uxmaan Ali


People also ask

Can I use static files in core ASP NET Core?

Static files such as Image files, CSS files and JavaScript JS files does not work in ASP.Net Core unless it is placed in proper location with the project and also some settings are set. In this article I will explain with an example, how to use Static files (Images, CSS and JS files) in ASP.Net Core.

How to include a JavaScript file in another JavaScript file?

How to include a JavaScript file in another JavaScript file ? In native JavaScript before ES6 Modules 2015 has been introduced had no import, include, or require, functionalities. Before that, we can load a JavaScript file into another JavaScript file using a script tag inside the DOM that script will be downloaded and executed immediately.

What is the file object in ASP NET?

These are the ASP.NET programming features introduced in the article: The File object, which provides a way to manage files. The FileUpload helper. The Path object, which provides methods that let you manipulate path and file names. This tutorial also works with WebMatrix 3.

Why can't I find the JS file in my page?

Probably the file is not in the path specified. '../../../' will move 3 step up to the directory in which the page is located and look for the js file in a folder named JS. Also the language attribute is Deprecated. Deprecated. This attribute specifies the scripting language of the contents of this element.


1 Answers

As far as I can tell, the hashes in your js file names are caused by the --prod flag in the angular-cli.

You basically have to options here:

  • remove the --prod flag
  • add --output-hashing none flag

That means you would end up with a build command similar to this:

ng build --prod --output-hashing none

Please note, that the hashes serve a specific purpose: Cache-Busting. Everytime you generate a new build, these hashes change and if you inject the script(s) automatically into a html file using the angular-cli, this has the benefit of not needing to check if you have to clear your cache and if the changes have been picked up by your browser or if they have been served from disk.

Documentation: https://angular.io/cli/build

like image 185
Marco Avatar answered Nov 15 '22 10:11

Marco