Problem with postback and user controls
Posted on 2007-08-01
Environment: ASP.NET 1.1, VB.NET, IIS
have an ASP.NET application in which I'm using user controls. I have the user controls in various sub folders.
On my user controls I have hyperlink server controls with their NavigateUrl properties pointing to other folders with .ascx controls, but I substitute the .ascx with .aspx.
In my Application_BeginRequest method I get the Request url and retrieve the path and name of page requested substituting the .aspx with .ascx. I then use Context.Rewritepath to change the request page to a common page (.aspx) and pass the control path and name as a querystring.
The problem I'm having is on PostBacks the request url will include the previous re-written url, but I want my url to look like it looked the first time the page was visited.
The page is being taken as if it was in the same folder as the user control where the postback is from.
If I try to remove the previuosly re-written part from the url by specifically pointing to the common page I get the following error:
The virtual path '/Default.aspx' maps to another application, which is not allowed.
My Default.aspx page is actually in the root of my application folder. The folder is set up as an application in IIS.
Thanks in advance for the help