In ASP.NET Core this works out of the box via the asp-append-version
tag helper:
<script src="scripts/myjavascript.js" asp-append-version="true"></script> <link href="styles/mystyle.css rel="stylesheet" asp-append-version="true" />
Daily Notes of a Programmer