I have a partial view that is used in 2 places, one is using a view model within a post model with a manually added HtmlPrefix, so the field id looks like this:
id="Model_Address_AddressLine1"
In the other place I don't need a view model and the id is just "AddressLine1". It is the same partial view however.
However if i visit the page with "Model_Address_AddressLine1" first, IIS caches this partial view and then when I go to the other page it doesn't model bind and validate as the id is cached as "Model.Address.AddressLine1" and it doesn't pull "AddressLine1".
I have tried making the ajax call set to cache:false and set NoStore on the actions OutputCache attribute, but it still caches the partial views model ids and name, is there a way to stop it doing this?
Added this code if it helps, this is helper code that adds the prefix on one of the pages for the partial view, but not the other:
return helper.Partial(partialName, accessor.Compile().Invoke(helper.ViewData.Model),
new ViewDataDictionary(helper.ViewData)
{
TemplateInfo = new TemplateInfo
{
HtmlFieldPrefix = prefix
}
})
Response headers confirm caching:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8 Accept-Encoding:gzip,deflate,sdch Accept-Language:en-US,en;q=0.8 Cache-Control:max-age=0 Connection:keep-alive Cookie:__RequestVerificationToken=qnKmH92lRoXCZWl_146N3uPiGRnWJCRZis6V_6cQ7mUJUdlVfAQVAxeTBtnhdTgM2s_NezoZghhwCrqBrv4GcjrCZr0XhG-6bHq7kfhlRrw1; ASP.NET_SessionId=dh225cux11sckpxl2uke30q3; FedAuth=77u/PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48U2VjdXJpdHlDb250ZXh0VG9rZW4gcDE6SWQ9Il9iZTI5MDk4OC01ZjdjLTQyZTktYjMxOS0zOGJhYzM5OTBlMjctMzg3NTUxQjQyM0JENjFDQzIwMEQyQTc2MTRBQzBDMDYiIHhtbG5zOnAxPSJodHRwOi8vZG9jcy5vYXNpcy1vcGVuLm9yZy93c3MvMjAwNC8wMS9vYXNpcy0yMDA0MDEtd3NzLXdzc2VjdXJpdHktdXRpbGl0eS0xLjAueHNkIiB4bWxucz0iaHR0cDovL2RvY3Mub2FzaXMtb3Blbi5vcmcvd3Mtc3gvd3Mtc2VjdXJlY29udmVyc2F0aW9uLzIwMDUxMiI+PElkZW50aWZpZXI+dXJuOnV1aWQ6YTM1MWFmNjItYzU0Mi00MzQ2LWI2NzYtNGIyNjE0Y2YxMjU2PC9JZGVudGlmaWVyPjwvU2VjdXJpdHlDb250ZXh0VG9rZW4+ Host:127.0.0.1:444 User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36 Response Headersview source Cache-Control:no-cache, no-store Content-Encoding:gzip Content-Length:9958 Content-Type:text/html; charset=utf-8 Date:Tue, 13 May 2014 08:15:52 GMT Expires:-1 Pragma:no-cache Vary:Accept-Encoding X-Frame-Options:SAMEORIGIN