Walter.BOM Namespace
Walter.Web.FireWall Namespace
ASP-WAF | .Net API for WAF Systems

NoCacheAttribute Class

Tells the razor engine to include not cash the response in any form or way guarantying that the action is re-executed

Namespace:  Walter.Web.FireWall.Annotations
Assembly:  Walter.Web.FireWall (in Walter.Web.FireWall.dll)

Syntax


public sealed class NoCacheAttribute

Remarks


Sometimes it's helpful to ensure a action is not cashed especially if the action generates user JavaScript that is dependent on the page.

Examples


The bellow example injects the pageId and userSalt in a virtual java script file that will always re-load when a page is requested. this allows you to avoid the need to pass parameters to trick cashing in the browser.
C#
public class HomeController : Controller
{
    private readonly IPageRequest _page;

    public DocumentationController( IPageRequest page)
    {
        _page = page;
    }

    [Route("js/Variables.js")]
    [NoCash]
    [Ignore(skip: FireWallGuardActions.EmbeddedResources)]
    public FileResult Script()
    {
        var sb = new StringBuilder();
        sb.AppendLine($"var userSalt ='{_page.User.GetUserSalt()}';");
        sb.AppendLine($"var pageId = {_page.PageRequestGroupId};");

        byte[] java = System.Text.Encoding.UTF8.GetBytes(sb.ToString());
        return File(java, "application/javascript");
    }
}