问题描述
||
创建新合同时,我会向所有相关方发送电子邮件。但是,电子邮件中的链接将打开一个新屏幕,但是只有当我按F5键时,我才能看到页面登录页面,然后才是我要导航到的页面。我该如何解决?
一个典型的链接是
http:// localhost:3838 / Contract / Details / 14
我的控制器动作是
/****************
* DETAILS
************* */
[Authorize(Roles = \"Reader,Inputter,Administrator\")]
public ViewResult Details(int contractId)
{
return View(new Contractviewmodel(contractId));
}
解决方法
测试期间,浏览器可能会缓存网站吗?
听起来您正在使用IE的新版本,所以:
Go to Tools --> Internet Options --> Temporary Internet Files --> Settings.
Set it to check for newer versions of stored pages \"Every visit to the page\".
或者,如果您更喜欢代码修复,则可以在控制器上使用NoCacheAttribute,尽管不建议这样做,因为您最终可能希望进行缓存:
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public sealed class NoCacheAttribute : ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
filterContext.HttpContext.Response.Cache.SetNoStore();
base.OnResultExecuting(filterContext);
}
}
[NoCache]
public class YourController : Controller
{
...
}