We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


asp.net/ajax: unable to locate root directory on httphandler webpage?!?

Goalie3533 asked
Medium Priority
Last Modified: 2012-05-06

I'm using DotNetBlogEngine as my infrastructure for an asp.net blog website.  DotNetBlogEngine creates "fake" pages for all blog articles and category pages.  The problem is, when I integrate ajax into one of these "fake" httphandler pages, and then execute the ajax (a button click event in this case), I get errors related to being unable to locate the root directory....

 If you check out my site at (not much to look at.  Just wanted to upload to show the error) , then click the square, blue button on the top right called "Click Here", you'll notice you can click it over and over with no problem.  The content in the blue bar successfully switches back and forth.

Now, however, if you click on the "General" link under "Categories" on the left hand side of the page, this page leads to the error I'm having.  If you click the blue square again on this General page, it works fine the 1st click however the 2nd click should return an invalid image URL when trying to display the original phone advertisement again.  Notice the URL of this page is called "category/General.aspx"?  This page doesn't actually exist.  It's a "fake" page DotNetBlogEngine creates via httphandlers.  Now, if you right click on the invalid image, the URL it displays is "category/images/templateimages/ad.jpg" .  The correct path should not have "category" in it.  

 My imagepath in my image control looks like the following:

Any idea what may be causing this to not look in the root directory?

Watch Question

Could you tell what script you are writing in Click Here? Are you changing the ImageURL manually anywhere in the code?


Hi lotusnotesnewbie.  Thanks for the reply.

I've attached the code I use to execute this (also included my scriptmanager).  Strange thing is I'm not doing too many crazy things.  I just basically have two panels.  One's always visible & the other's invisible when the button (lnkOpen_Close) get clicked.

I'd greatly appreciate any extra help or advice you can offer.

Thanks again.
            ScriptMode="Release" />
<asp:LinkButton ID="lnkOpenClose" runat="server" OnClick="lnkOpenClose_Click" Width="136" Height="145" CssClass="OpenCloseButton"></asp:LinkButton>
<asp:UpdatePanel ID="OnPageMenuUpdatePanel" runat="server" UpdateMode="Conditional">
          EventName="Click" />                        
     <asp:Panel ID="pnlDefault" runat="server" Visible="true">
         <table width="100%">
                   <td align="center" valign="middle">
                        <asp:Image ID="imgAd" runat="server"    
                        ImageUrl="~/images/templateimages/ad.jpg" />
     <asp:Panel ID="pnlMenuOptions" runat="server" Visible="false">
            ....PANEL CONTENT HERE....          
c# code:
    protected void lnkOpenClose_Click(object sender, EventArgs e)
        if (pnlMenuOptions.Visible == true)
              pnlMenuOptions.Visible = false;
              pnlDefault.Visible = true;
              pnlMenuOptions.Visible = true;                           
              pnlDefault.Visible = false;

Open in new window

I was able to resolve this error with a solution from someone else.  Here's the solution they posted:

I was able to reproduce the problem you're having on my local machine.

The problem is that when you're on the category page, the first time you do an UpdatePanel button click, the async postback is correctly being done to "category/BlogEngineNET.aspx", but the response coming back to the page includes a new 'formAction' with a value like '../default.aspx?id=19770e74-9ec9-4cde-b2ab-e5051aaaf348'.  Then the next time you do an UpdatePanel button click, the async postback is being incorrectly done to ../default.aspx?id=19770e74-9ec9-4cde-b2ab-e5051aaaf348.

I did this Google search and found one solution that solved the problem (there may be other solutions too -- didn't search for very long).  The solution I found was here.  If you add JeffreyZhao's code somewhere in your page, it fixes it so the async postbacks are done to the correct url.  I added his code right before the closing <body> tag.

<script type="text/javascript">
        var form = Sys.WebForms.PageRequestManager.getInstance()._form;
        form._initialAction = form.action = window.location.href;

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.