Pages

Saturday, 26 February 2022

Force to Refresh Javascript and CSS files on page load

 To force Javascript and CSS files on every time while page load is good practice when working on live operation because when you made any change in CSS and Javascript files then updated content reflects when cntl + f5 pressed otherwise system get file from cash to save to reload time. Given code below help you to force reload file on every page load in C# ASP.Net MVC.


@{
    Random ob = new Random();
    int ran = ob.Next();
}

<script src="~/AppJs/product.js?v=@ran"></script>
<link href="~/AppCss/gcss.css?v=@ran" rel="stylesheet" type="text/css">

No comments:

Post a Comment