2

I have 3 .aspx files. For example

GrandFather.aspx, Father.aspx and Child.aspx

GrandFather.aspx page has an Iframe and the iframe's source is Father.aspx. Form Father.aspx, I called Child.aspx by using

Resposne.Redirect("Child.aspx");

As a result the iframe content has been changed with Child.aspx. Now the Child.aspx has some form-data which are submitted in its postback. Browser IE, FireFox, Google Chrome it has been working properly but in Safari, it shows the following error,

System.Web.HttpException: A field validation of viewstate MAC. If a Web Farm 
or cluster is hosted by this application, please check that you have to specify 
the configuration is the same validationKey and validation algorithm <machineKey>.
AutoGenerate can not be used in the cluster.

What can be the reason behind this problem? How can I solve it?

I have checked the source of the Iframe and it shows always Father.aspx even after Response.Redirect.

I am using .NET 2.0 and IIS is 6.0.

EDIT:

For first time postback the Safari browser shows the error. However, for the next try, the error goes away.

Nazmul
  • 6,658
  • 12
  • 49
  • 61
  • Have you checked this out? http://community.discountasp.net/showthread.php?t=2719 – Lloyd Nov 02 '11 at 07:43
  • @Lloyd I have checked it and my issue is only for Safari. IE, Firefox, Google Chrome do not show the above mentioned error. – Nazmul Nov 02 '11 at 10:47

1 Answers1

0

My company recently ran into an issue with Safari + IFrame + Cookies.
Basically, Safari doesn't accept any cookies the first time it loads an Iframe. This of course causes all kinds of havoc, causing all authentication and sessions to not work.

Here is a related question that has to deal with Same-Origin-Policy.
It says that Safari will behave once the user has interacted with the Iframe page. They suggest a workaround, which is to use JavaScript to POST an empty form, and Safari actually considers this "user interaction". After the page refreshes, Safari will behave properly thereafter.

Our solution was to simply break-out of the Iframe for Safari users. This was not an ideal solution but is all we really needed.

Community
  • 1
  • 1
Scott Rippey
  • 14,881
  • 5
  • 68
  • 83
  • Thank you so much. In my case, the first postback shows error and for the next try, the error goes away. – Nazmul Nov 02 '11 at 10:50
  • Yeah, that totally fits the Same-Origin-Policy issue. Safari initially discards the cookies for the Iframe, but once the Iframe has "user interaction" (which includes any POST), it behaves normally. The "workaround" as suggested in the linked article is to use JavaScript to simulate a POST, which will refresh the page and Safari will behave thereafter. – Scott Rippey Nov 02 '11 at 16:45
  • Merged my comment into the answer – Scott Rippey Nov 02 '11 at 16:50
  • Thank you once again. In my case the pages in iframe are from the same domain not from different domain. – Nazmul Nov 02 '11 at 22:27