Hi,
Is there a generic way or some configuration we need to do to apply versioning to JavaScript files?
Currently, we are using asp-append-version="true" when including JavaScript files in our HTML, as shown below but it is not working:
@section Scripts { <script type="text/javascript" src="~/view-resources/Areas/App/Views/clients/index.js" asp-append-version="true"></script> } Looking forward to guidance on resolving this issue.
5 Answer(s)
-
0
Hi @kansoftware
A script tag with asp-append-version="true" adds the src path of the relevant file with the version parameter. Here in your project, in your Startup file,
app.UseStaticFiles();Make sure it is attached. By default, these settings are available in ASP.NET Zero. If you still have the problem after checking these, can you give more details? In the inspect section, you can see what kind of url structure the file was added to. We also recommend that you use the "abp-src" attribute since the min file of your javascript file is automatically created by gulp.Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi,
We are already using app.UseStaticFiles() in our Startup file. However, after inspecting the browser's network section, we see the following:
/view-resources/Areas/App/Views/clients/index.js?v=ARUfqU9IfxpqYpruFCH0eHhwijWK7_D18dJI98XrYjE
To include JavaScript files in our HTML, we are using the following code:
@section Scripts { <script type="text/javascript" src="~/view-resources/Areas/App/Views/clients/index.js" asp-append-version="true"></script> }
Despite this, we still need to perform a hard refresh after every deployment for the latest changes to take effect, which we would like to avoid. Could you please advise on how to ensure the changes take effect without requiring a hard refresh?
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi @kansoftware
Using ABP attributes when importing JavaScript and style files provides an easier way to apply new versioned JavaScript and styles during deployment. Use "abp-src" for JavaScript files and "abp-href" for style files. After applying these attributes to the relevant files, you need to run the "npm run build" command when preparing the application for deployment. This ensures that the changes are reflected in the minified and bundled files. Once you have deployed your application, you can notify users of the update and ensure they receive the updated styles and JavaScript files by using the "Send New Version Notification" button on the Maintenance page.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi, Below is an example of the code used to open a partial view. I want to ensure versioning is applied to the ActionItem/CreateAssignedActionItem.js file.
var _createOrEditModal = new app.ModalManager({ viewUrl: abp.appPath + 'App/ActionItem/CreateAssignedActionItem', scriptUrl: abp.appPath + 'view-resources/Areas/App/Views/ActionItem/CreateAssignedActionItem.js', modalClass: 'CreateAssignedActionItem' });
$('#Create').click(function () { _createOrEditModal.open(); });
How can I include versioning in the scriptUrl for the JavaScript file to ensure that the latest version is always fetched when the partial view is loaded?
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0

