Problem with postback and user controls

Posted on 2007-08-01
Last Modified: 2013-11-26
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
Question by:jojoSoneHead
    1 Comment
    LVL 18

    Accepted Solution

    That is the tricky part of URL Rewriting.. check out following 2 solutions to overcome this problem:

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re… provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
    Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now