Tells the razor engine to include not cash the response in any form or way guarantying that the action is re-executed
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.
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");
}
}
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2