onurkaygn
onurkaygn

Reputation: 17

Page Loader Stuck When Clicking Browser Back Button in .NET MVC Website

I'm developing a website using .NET MVC, which can be accessed at https://gengecmimarlik.com . The site uses a page loader animation that works as expected during normal navigation through the navbar links. However, I encounter an issue when using the browser’s back button.

Problem: When I navigate to a different page (e.g., /TumProjeler or /iletisim) and then press the back button on the browser (Chrome or Edge), the loader animation appears but stays stuck, preventing the page from loading properly. The site doesn't crash or throw any errors, but the loader does not disappear, and the page content doesn’t show up. If I remove the preloader, the problem disappears, but I need to keep it for design purposes.

Key Details:

<a class="rd-nav-link" asp-controller="Home" asp-action="Index">Ana Sayfa</a>
<a class="rd-nav-link" asp-controller="Home" asp-action="AllProjects">Tüm Projeler</a>
<a class="rd-nav-link" href="@Url.Action("Index", "Home")#ekibimiz">Ekibimiz</a>
<a class="rd-nav-link" asp-controller="Home" asp-action="Contact">İletişim</a>

Any advice or suggestions would be greatly appreciated. Thank you!

Edit: The repo below contains the HTML of the loader and the scripts used by the loader. I couldn't add all of them to the problem due to the character class. If this is a behavior that does not comply with the rules, I apologize, I am relatively new to stackoverflow. https://github.com/onurkaygn/loader If you think the problem is not with the scripts but with something else, I can share the other folders as well.

Upvotes: 0

Views: 106

Answers (1)

asmak9
asmak9

Reputation: 274

Add these lines of code in the "Global.asax.cs" file i.e.

protected void Application_BeginRequest()
{
    Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
    Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
    Response.Cache.SetNoStore();
} 

Upvotes: 0

Related Questions