I have the following folder structure:
Pages/
|- Account/
|- Login/
|- index.cshtml
|- Shared/
|- _Layout.cshtml
|- wwwroot/
|- 0.png
|- 1.png
_Layout.cshtml
:
<img id="landing_page_image" src="~/0.png" alt="Login" style="height: 100%; width:100%"/>
<script type="text/javascript">
setInterval(function() {
let img = document.getElementById('landing_page_image');
img.src = `~/${Math.round(Math.random())}.png`;
}, 6000);
</script>
I get the following error as seen in the browser console:
Account/Login/~/1.png 404
The path is wrong. How to access wwwroot/image.png
from the javascript in _Layout.cshtml
?