Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 22, 2008 06:13 PM by brianwolfe86
Dec 16, 2008 10:02 PM|LINK
Is there a way to force Response.Redirect or Server.Transfer methods of the Page class to change "IsPostBack" to true?
Basically, I'm trying to circumvent making a form submit to another page because every time I do, I receive the error "Validation of Viewstate MAC failed" (which seems to be a common problem for people running server farms, but I'm just running it on a simple
If anyone has any advice on how to accomplish either of these, I would greatly appreciate it.
Let me know if you need to see my code.
Dec 16, 2008 10:40 PM|LINK
Ispostback can only be set by a page posting back to itself (hence the name). For scenarios like yours, cross-page postback was introduced in asp.net 2. You may want to try it.
Dec 16, 2008 10:42 PM|LINK
Do you get this on both Response.Redirect and Server.Transfer?
You can set at your Page attributes:
Which would prevent asp.net performing the viewstate check for cross posting between pages.
Hope that helps,
Dec 18, 2008 03:05 PM|LINK
Well, I tried this in both pages and still receive the error.
hooligannes97, can I use this in conjunction with Response.Redirect and/or Server.Transfer? I could have sworn I gave that a shot, but that variable never changed...
Dec 18, 2008 03:16 PM|LINK
I just tested this and the IsCrossPagePostBack always returns false no matter if I transfer from another page or if I refresh.
Any idea why this might be?
For reference, here's how I'm transferring the page:
Dec 18, 2008 10:54 PM|LINK
Brian, a redirect is not a postback, it's a redirect. [;)]
If you use Transfer or a crosspage postback, this information will help you understand how to get the correct postback value you are looking for (From a
post at Dino Esposito's Blog):
This code never worked as expected, in Beta 1 as well as in Beta 2. Recently, I realized it was my fault as
IsCrossPagePostBack is designed to return true for the PreviousPage page object, not for the current page. In other words, it returns true for the page which STARTED a cross-page posting, not for the page being invoked that
The PreviousPage property and the
PreviousPageType directive are useful in two situations where you invoke the target page: in a cross-page postback, which is a client-based transfer, and with the
Transfer method, which is a server-based operation. In both operations, code
in the target page can get a reference to the source page using the PreviousPage
It might be important in the target page to determine whether the page was invoked from a cross-page posting or a
Server.Transfer operation. To help you do this, the
Page class exposes a property named
IsCrossPagePostBack. For details, see
How to: Determine How ASP.NET Web Pages Were Invoked.
Dec 18, 2008 11:21 PM|LINK
Sorry, I know I can be a bit thick at times, but do you think you could tell me why this wouldn't work if I changed the code to use Server.Transfer on the source page and the following code on the target page? I just tried this configuration and IsCrossPagePostBack
always returns false.
if (PreviousPage != null)
if (PreviousPage.IsCrossPagePostBack == true)
newItems = null;
Dec 19, 2008 02:05 PM|LINK
Anyone? I would really appreciate the help as this is very urgent.
Dec 19, 2008 02:32 PM|LINK
This error occurs when u a viewstate from source page is passed to destination page. for more details read my post on viewstate
Dec 19, 2008 04:22 PM|LINK
I changed my page directive on my destination page to read as follows:
<%@ Page Language="C#" Debug="True" ContentType="text/html" Inherits="otherCode" src="cart.cs" EnableViewStateMac="false" %>
And my transfer code on my source page reads like this:
But IsCrossPagePostBack still evaluates to false no matter if I refresh or if I post from my source page.
Am I missing a step?