Using Server.Transfer and EnableViewStateMac

Most of the people use Server.Transfer for simply to transfer from one page to another. There are other advantages of it also.

Server.Transfer has two overloaded methods. The first argument is Page name and the second argument is a boolean.

Ex: Server.Transfer(\\[boolean\\],true);

If this boolean is set to true, when the transfer happens the request collection will also be transfered to the next page. There by allowing us to access the values through request collection.
This helps when we have lot of data has to be sent from one page to another page.

But when we use this method we need to disable view state check for the receving page.
This has to be done because ASP.Net engine validates the view state that is present in request collection. Since that view state will not be same as that of the current page, ASP.Net engine throws an exception.

So to disable view state validity check, we need to set EnableViewStateMac to false.
This does not effect the page from maintaining the view state instead it simply ignores the changes to view state.
But we need to be careful enough in disabling view state verification as there may be a chance of attack.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish