【问题标题】:How do I use caching in an MVC 5 web application?如何在 MVC 5 Web 应用程序中使用缓存?
【发布时间】:2019-02-13 20:29:55
【问题描述】:
Line 56:<cache expires-after="@TimeSpan.FromSeconds(120)">

Line 57:Current Time Inside Cache Tag Helper: @DateTime.Now

Line 58:</cache>

//我收到此错误消息

“/”应用程序中的服务器错误。 解析器错误 说明:解析服务此请求所需的资源时出错。请查看以下特定的解析错误详细信息并适当地修改您的源文件。

解析器错误消息:应为“}”。

【问题讨论】:

  • 那么,您在 OutputCache 属性中使用了哪些属性?如果你也可以分享代码会很有帮助
  • 我能够解决该错误。我找到了一个关于缓存 asp.net mvc 的有用网站,这是我使用的网站:techfunda.com/howto/276/store-data-into-cache-in-asp-net-mvc。感谢您的回复。

标签: c# .net caching


【解决方案1】:

我能够解决错误。我找到了一个关于缓存 asp.net mvc 的非常有用的网站,这是我使用的网站:techfunda.com/howto/276/store-data-into-cache-in-asp-net-mvc。它包含有关不同类型缓存的信息,并详细说明了每种缓存类型的作用。

//在我的控制器的action result方法中为我想要缓存的视图添加代码

[OutputCache(CacheProfile = "Cache", Location = System.Web.UI.OutputCacheLocation.Server)]

//在网页配置中添加的代码

<caching>
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="Cache" duration="30" varyByParam="none"/>
        </outputCacheProfiles>
      </outputCacheSettings>
</caching>

有关缓存的更多信息,请访问以下网站:techfunda.com/howto/276/store-data-into-cache-in-asp-net-mvc。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-06
    • 2013-09-27
    • 2015-11-11
    • 1970-01-01
    • 2010-09-25
    • 2016-04-16
    相关资源
    最近更新 更多