Click here to Skip to main content
12,758,605 members (32,021 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 27 Jun 2010

Url Rewriting Problems with postback

, 28 Jun 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
I was developing a system that used Url Rewriting, when a button was clicked the whole page broke.

I came across a error like


And as the error said something about viewstate and machine keys I tried to work at getting the machine key to work properly with a static machine key, this was never working. So I set “enableEventValidation” to false and this didn’t break when doing the postback. I noticed that I was redirected to the home page as the web.config stated when checking the rules for rewiting that if a page was under the modules folder it needed to check the page and redirected the servers attention to another page (CommandPanelLeft.aspx) which is the parent page for modules. So I said if there is a querystring of modulename then leave the page alone. Now the postback works fine but the url says the path that the server reads (a) with the querystring instead of the rewriten url (b)





So I took the code out the Global.asax to ignore pages with the querystring containing moduleName and also took out the “enableEventValidation” in web.config, and on the page_load method on the master page I added a line of code I found

This says to the page that that is the url that it must make the postback on.


The problem wasn’t the machine key or faulty viewstate it was that in my global.asax I was redirecting to the home page if the page that was in the browser (b) wasn’t found and because when the postback was made the url was now set to (a) in the browser because when it loaded the last time the server read it as (a) because we told it that was the path, it was posting back to that path. By adding the line of code to the master page we were telling the page that “Request.RawUrl” is the pages actual page name and not “CommandPanelLeft.aspx” the postback went to the page that we rewrote the url to.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Junior) nologo studios
South Africa South Africa
No Biography provided

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 28 Jun 2010
Article Copyright 2010 by gbeeming
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid