आउटपुट कैश को नीचे कोड का उपयोग करके एएसपी.नेट एमवीसी 2 में लागू नहीं किया जाता है।क्यों GetVaryByCustomString को
GetVaryByCustomString
विधि को नहीं कहा जाता है: अपनी पहली पंक्ति में ब्रेकपॉइंट लगाकर और चलने वाले एप्लिकेशन से पता चलता है कि ब्रेकपॉइंट नहीं पहुंचा है। नियंत्रक सूचकांक() में ब्रेकपॉइंट तक पहुंच गया है।
एएसपी.नेट एमवीसी 2 में VaryByCustom
का उपयोग कैसे करें?
नियंत्रक:
[OutputCache(VaryByCustom = "user")]
public ActionResult Index(string _entity, string id)
{
...
Global.asax.cs:
public class MvcApplication : System.Web.HttpApplication
{
public override string GetVaryByCustomString(HttpContext context, string arg)
{
if (arg == "user")
{
HttpCookie cookie = context.Request.Cookies["Company"];
if (cookie != null)
return Thread.CurrentPrincipal.Identity.Name + "," + cookie.Value;
return Thread.CurrentPrincipal.Identity.Name;
}
return base.GetVaryByCustomString(context, arg);
}
}
धन्यवाद। इस वेरी को जोड़ने के बाद: * हेडर ब्राउज़र पर भेजा जाता है और यह ब्राउज़र कैश को अक्षम करता है। VaryByCustom के साथ ब्राउज़र कैश को कैसे सक्षम करें? – Andrus