开发者

Neither IE or Firefox respects the control values that are output

I'm writing a survey designer asp.net mvc. It has buttons to move questions up and down. The buttons post the whole form back and the affected questions are swapped on the server. When the form returns the only thing that is changed are the values for each survey question. Both firefox and IE seem to ignore this change.

Nothing is persisted to the database (until save) and url doesn't change so the post just returns the same view but I've stepped through my code to ensure the sequence of values being rendered in the view reflects the swap which is ok. However "view - source" doesn't show the change suggesting caching issue (maybe auto complete).

I've tried autocomplete="off" in my form.

Response.Cache.SetNoStore(); in my global.asax

[System.Web.Mvc.OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")] before my controller

and the following in my page header

<meta http-equiv=="CACHE-CONTROL" content="NO-CACHE" />
<meta http-equiv=="PRAGMA" content="NO-CACHE" />
<META HTTP-EQ开发者_StackOverflow中文版UIV="EXPIRES" CONTENT="0" /> 

I also tried putting a random query value in my url.

NOTHING!!! This must be real common.

Anyone got a clue?


Redirect to GET seems to fix it using TEMPDATA to pass the model that was posted from the client to the [HttpGet] view.

I don't know why browsers favor their cached input field values over what is returned from the POST yet give an honest representation of what is retrieved from a GET.

I just hope my users never hit refresh on a survey they are working as they will loose it as the TEMPDATA is blown away. This might actually be what they'd expect though and I generally like "POST then redirect to GET" as it prevents potentially damaging re-posting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜