Skip to content

kamranayub/aspnetmvc5-asset-versioning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AspNet.Mvc.AssetVersioning

Adds a UrlHelper.VersionedContent URL extension helper to append SHA256 hash to content URLs in ASP.NET MVC 5.

Install

Install-Package AspNet.Mvc.AssetVersioning

Usage

In Views/web.config, add:

<configuration>
  ...
  <system.web.webPages.razor>
    <pages ...>
      <namespaces>
        ...
        <add namespace="System.Web.Mvc.AssetVersioning"/>
      </namespaces>
    </pages>
  </system.web.webPages.razor>
</configuration>

You can then use the helper in .cshtml files like so:

<script type="text/javascript" src="@Url.VersionedContent("~/scripts/jquery.js")"></script>

And the helper will append a query string parameter containing the SHA256 hash of the content. This is cached for the lifetime of the request cache (HttpContext.Cache).

About

Versioned content URLs in ASP.NET MVC 5

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy