Force update of an element in HTML / Javascript / ASP.NET

0

Greetings, friends of Stack Overflow. I have a question that involves updating the data entered by the user.

On the site I'm working on, the user has access to a text editor to change the labels on certain photos. When editing the text and submitting the answers, the texts do not update on the pages - The same thing happened with the images of the site, but a solution was found, putting a random number at the end of all of them, maintaining uniqueness. p>

The following photos demonstrate what I mean:

Theaboveimagehasalabel(MilitaryPolice,Navigators).

Belowyouhavethepossibilitytochangeboththeimageandthetextdisplayednexttoit:

Unfortunately,thevaluesdonotupdate.Thesamethinghappenedwiththeimages,butasitwassaid,arandomidentifierwas"pasted" in its name to the server (Azure) not to confuse.

What can be happening? (I'm using cshtml / aspnet with mvc5!)

I have already tried several alternatives (both in English and Portuguese) - most of them inform on meta tags that include the options "no-cache", "no-store", among others, but none seems to work. >

Thank you in advance!

    
asked by anonymous 18.12.2017 / 17:47

2 answers

1

Hello,

Maybe it's not the View but the method you use to bring the contents of the database. If you are using EF to query in DB, try to do it through a string query (eg "SELECT (fields) FROM dbo.Tabela") and execute with Database.SqlQuery (QUERY) .ToList ()

This causes the data to actually be fetched from the database, forcing the update.

Att.

    
18.12.2017 / 19:20
1

In the signature of every Action that you do not want to cache put the following annotation: [OutputCache(NoStore = true, Duration = 0)] in the following example I had problem with cache and I solved it that way.

[OutputCache(NoStore = true, Duration = 0)]
public ActionResult LoginRegister()
{
}

Source (my own question is a different purpose, but the workaround is the same): How to not allow the user to access the previous login / registration page after signing in or sign up

If it does not resolve, comment that we'll find another solution.

    
18.12.2017 / 17:56