Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Forcing the views to update in ASP.NET Core 3.1.10

Forcing the views to update in ASP.NET Core 3.1.10

Scheduled Pinned Locked Moved .NET (Core and Framework)
asp-nethelpquestioncsharpdotnet
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Leif Simon Goodwin
    wrote on last edited by
    #1

    I have an Asp.Net Core web application with some simple pages. I have a shared layout with the page content rendered as follows:

                        @RenderBody()
    

    The problem is that when I make changed to the content, they don't appear when I debug the web site, which means that it is impossible to for me to work on the web site. I found some suggested fixes online. I updated the startup as follows:

        public void ConfigureServices(IServiceCollection services)
        {
            System.Data.Common.DbProviderFactories.RegisterFactory("System.Data.SqlClient", System.Data.SqlClient.SqlClientFactory.Instance);
            var mvcBuilder = services.AddControllersWithViews();
    

    #if DEBUG
    if (IWebHostEnvironment.IsDevelopment())
    {
    mvcBuilder.AddRazorRuntimeCompilation();
    }
    services.AddRazorPages().AddRazorRuntimeCompilation();
    #endif
    services.Add(new ServiceDescriptor(typeof(Services.IKeyManagerFactory), new Services.KeyManagerFactory()));
    services.AddMvc();
    }

    But that doesn't help. I have tried other suggested fixes with no joy. For example in the startup Configure method:

            app.UseStaticFiles(new StaticFileOptions()
            {
                OnPrepareResponse = context =>
                {
                    //context.Context.Response.Headers.Add("Cache-Control", "no-cache, no-store");
                    context.Context.Response.Headers\["Cache-Control"\] = "no-cache, no-store, must-revalidate, max-age=0";
                    context.Context.Response.Headers.Add("Expires", "-1");
                }
            });
    

    How do I force the views to update?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups