We've been developing a shop web app for the last 4 years. Now, we're adding a new feature, so the app would behave in two different ways depending on configuration:
The first way is just a normal web app
The second way works in the following way:
- Associate a domain or subdomain to one product
- When an user visit that domain, the shop must show the product page. The app doesn't allow the user to visit any other page except those for checkout
- The user clicks on a buy button and then the app redirects him/her to the checkout page
At first, we thought about Server.Transfer
, so we wrote in Global.asax
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (check for conditions)
{
Server.Transfer("product.aspx", true);
}
}
The first issue with this approach was the Session. When the product.aspx loads, it has no Session initialized, so it fails.
Then we put that code in Application_PreRequestHandlerExecute
but, then we had issues with postbacks. We already knew that Server.Transfer
has problems with that, but with the second parameter being true
, it should be solved. We also set EnableViewStateMac="False"
, as there's a redirect to the checkout aspx, but that doesnt works neither. No matter what we do, the app fails authenticating the ViewState or it doesn't respond to the postback.
Another solution we tried, was to try to change the default page programatically, but this doesn't seem to be possible. If we change the default page in the web.config by hand, the app works fine but sadly this is not allowed.
So the questions are:
Should we use Server.Transfer (assuming it can be done)? Can the default page be changed in some way, external config files or programmatically? Maybe we're just wrong with our approachs and there are better ones, though we've been unable to image it
Oh! I almost forgot: We're using aspx .net framework 2.0 and C# .net 3.5
I hope I have explained it well
Thanks in advance!
You may find the following useful from the MSDN help pages http://support.microsoft.com/kb/316920 I believe you have to do as you already suggested and set
EnableViewStateMac="False"
additionally you then need to either not pass the true param or send false (which is the default) when you callServer.Transfer
so go from this:To this:
or this: