Browser does not fetch page or link not working if link is to current page

Browser does not fetch page or link not working if link is to current page. In the code sample below, I have a link (in a menu). If the user is currently in the GetData page, and the user clicks on the "Get Data" link again, nothing happens. The browser does not attempt to retrieve the page. I've monitored this in IE8 and Chrome developer tools. Any idea?

//Link
<a href="@Url.Action("GetData", "Data")"><i class="glyphicon glyphicon-tag"></i>Get Data</a>

//Controller has a custom Authorization attribute
[AuthorizeRedirect]
public class DataController : Controller

// Controller Action Invoked
[HttpGet]
public ActionResult GetData(int parameter)
{
   ...
}

I created a test web application from scratch and the page is refreshed even when I click on a link to a page that is currently loaded.

I compared both response headers from the application and the test application and noticed a difference in the cache header.

My application contains the following:

Cache-Control:no-cache, no-store

While my test application contains only the following:

Cache-Control:private

Additional Info: I am using Angular JS and Bootstrap client side.

Answers


I thing it happens because of caching of Browser. Clear the Browser cache and try again. hope that i will help


How about setting the Headers inside the Application_PreSendRequestHeaders event in Global.asax?

You can use Response.Cache.SetCacheability rather than setting the Headers directly.*

void Application_PreSendRequestHeaders(Object sender, EventArgs e)
{
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
}

Alternative way by setting the Headers manually.

void Application_PreSendRequestHeaders(Object sender, EventArgs e)
{
    Response.Headers.Set("Cache-Control", "no-cache");
}

If you don't want no caching everywhere then you might try something like this:

[OutputCache(Location = OutputCacheLocation.None)]
public class HomeController : Controller
{
...
} 

Need Your Help

page before database - phonegap

cordova web-sql

I have a page that has to display information from a websql database.

How do I make the unresponsive script warning come up?

javascript firefox firefox-addon

I am making a firefox extension and I have a manual script entry box. I don't want the script to hang the browser when it is run. How can I make an unresponsive script error popup come up if the sc...