Do not cache a View using Asp.NET

Asked

Viewed 28 times

0

I have a popup that renders another View using the RenderPartial().

@Html.DevExpress().PopupControl(
    settings =>
    {
      settings.Name = "pcModalMode";

      settings.Width = 550;
      settings.Height = 420;

      settings.CallbackRouteValues = new { Controller = "SearchEditButton", Action = "PopupPartialFilter" };
      settings.AllowDragging = true;
      settings.HeaderText = Resources.Resources.Pesquisar;
      settings.CloseAction = CloseAction.OuterMouseClick;
      settings.PopupAnimationType = AnimationType.None;
      settings.CloseOnEscape = true;
      settings.Modal = true;
      settings.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
      settings.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
      settings.SetContent(() =>
      {
        Html.RenderPartial("_PartialScriptsGridView");
      });
      settings.ClientSideEvents.CloseUp = "function(s, e){ pcModalMode.Hide();}";
      settings.ClientSideEvents.EndCallback = "function(s, e){ pcModalMode.Show(); }";
      settings.ClientSideEvents.Shown = "function(s,e){s.PerformCallback();}";

    }).GetHtml()

The problem is that in this View which is rendered, has methods javascript where do I use the Razor to print different methods according to the data passed in the model:

@if (!string.IsNullOrEmpty(Model.UseValueChangedEvent) && Model.UseValueChangedEvent.Equals("S")) {
  @Model.ControlName<text>_ValueChanged(cmb, null)</text>
}

This is being curled, causing every time I navigate to another screen my popup come with the curly code.

It would be like every time I move to another screen I render the partial again with the values sent in the model?

  • But is the cache coming from the browser or server? Try using the Outputcache attribute in your action that renders your partial. https://docs.microsoft.com/en-us/aspnet/mvc/overview/older-versions-1/controllers-and-routing/improving-performance-with-output-caching-cs

  • Are you sure you need Razor to print these different methods? Incidentally... should you have different methods? where is javascript? Also present a redeveloped version of the view.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.