ajax problem

Discussion in 'ASP.NET 2.0' started by vagelis, Jul 2, 2011.

  1. i have problem with ajax
    i use in my pc visual studio 2005 asp.net 2.0 and ajax 1.0.61025.0

    in my pc it plays well
    (i have done for begining a clock to show time with seconds and i plan to do a lot more)

    but on server i had a problem

    "Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. "


    i searched to the net and found a solution to copy some ajax dlls to the server.
    i copied 3 dlls
    AJAXExtensionsToolbox.dll,System.Web.Extensions.Design.dll,System.Web.Extensions.dll in the bin folder of the server
    i did it and now the page has not an error but goes very slow the timer
    the clock doesnt change every minute as it had to do but every 8 seconds


    eny idea??
    please help..
     
  2. I'll look into this for you, for now you might want to search the ASP.net forums.
     
  3. ok thanks i will wait for your reply..

    and to correct something wrong that i wrote in the first post

    "the clock doesnt change every second as it had to do but every 8 seconds"
     
  4. This typo is significant. When you first mentioned the page was updating every 8 secs rather than every minute it sounded like a bug in your code. Now you've advised the page is updating every 8 secs rather than every 1 second it sounds like the ajax framework is working correctly but there's latency in the network and at the server side preventing the page being updated as often as you'd like.

    You need to run a trace on the page to verify what's really going on here. By the sound of your symptoms, you'll see outbound calls from the client to server every second but a response for a partial page update coming back much less often.
     
  5. ok i will try to run a trace
    but i dont have experience at run trace..

    thanks a lo for replying
     
  6. i try to run trace(trace=true) but i receive this error
    timer sys.webforms.pagerequestmanagerparsererrorexception

    what does it happen??
     
  7. I'd probably run a fiddler trace on the page with the code completely unmodified to see what request / responses are going on. You can do this with http://www.fiddler2.com/fiddler2/
     
  8. ...Agree, Fiddler may be what is needed.
     
  9. OK what I see is:
    • requests are made roughly every 1 second
    • sometimes a response comes back very quickly and then another request is immediately made giving the impression that a 1 second update / 1 second clock update is possible
    • when a response comes back more slowly, the subsequent request is made after the response delay giving the impression of a stuck or broken clock
    • the request / response mechanism on a 1 second interval works much better in chrome than IE
    • the process generally suffers under loads - in other words if the browser is loading another page or if it has other ajax operations ongoing e.g. iGoogle widget updates, the process becomes very erratic
    • the size of the request response is very large for what's actually being done here highlighting how inefficient using an UpdatePanel, Timer and MS AJAX for a partial page update is
    IMHO it's time to rethink this strategy or realign your expectations of what's reliably achievable.
     
  10. so if i understand well (because my english are not perfect) you think that the problem is the low value of interval
    do you think that cannot be carried?

    or if this is not what do you think how can i solve the problem?
    i did that with th clock (interval 1 second) to find out whats going on with ajax and do something more complicated(i have done moving news in my pc that work )
     
  11. i use this code

    Code:
    <%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        Namespace="System.Web.UI" TagPrefix="asp" %>
    
    
    <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:Timer ID="Timer1" runat="server" Interval="1000">
            </asp:Timer>
            <asp:Timer ID="Timer2" runat="server" Interval="80">
            </asp:Timer>
            <div id="asproora" align="center" style="position:absolute; background-color:white;">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            
            <Triggers>
      <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
    </Triggers>
    
                <ContentTemplate>
                    <asp:Label ID="imerominiaora" runat="server" Text="not refreshed yet"></asp:Label>
                </ContentTemplate>
            </asp:UpdatePanel>

    and vb

    Code:
    Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            imerominiaora.Text = DateTime.Now.ToLongDateString & " " & _
              DateTime.Now.ToLongTimeString()
            'keimeno23.Text = Session("keimeno12").ToString.Length - Session("keimeno12arxi")
           
            
    
        End Sub

    maybe the problem is in AsyncPostBackTrigger?
     
  12. i also get this error in all browsers except ie
    sys.webforms.pagerequestmanagerparsererrorexception

    and firefox refreshes very slow
     
  13. You have a number of problems here:

    The MS Ajax framework is notoriously bloaty in terms of the data that's sent / received in a request / response; this is easily seen in fiddler. I strongly recommend you learn how to use it. Read the instructions on the website to get started.

    I've attached a sample request / response trace for a single ajax update panel update along with the stats for that single call. If you take a look, you'll see that a single request is 57k upstream and the response is 55k downstream. Most of this is viewstate data and not even required to be sent in the round trip for the purposes of updating a span tag asynchronously. This a side effect of using the MS Ajax framework. The latest incarnations of MS Ajax are a bit better than this however if you want really lightweight Ajax, MS Ajax is definitely not it.

    I also included stats in the zip file for this single request / response and it shows the overall elapsed time for this single session was 0.892 msecs. As I watched a number of other requests go through, some were quicker but some were much slower - up to 3.5 seconds for one that I witnessed. This is a symptom of a busy network and to some degree the web server under load.

    This evidence shows that it's not possible to expect to get a response from a remote web server within a finite length of time because this really isn't how the internet works. The situation gets worse if an application is coded such that it expects to get a response in a very short time interval (< 1sec). This assumption may be achievable if the application was hosted in a private network with dedicated server side hardware. Attempting this on the internet with a shared host web server is not going to work.

    Please understand that I'm not criticizing the performance of the DASP hardware or infrastructure here. This is a poorly coded application making unrealistic assumptions about the environment in which it's operating.

    You can help matters by reducing the bloat (viewstate) in the ajax call. You could help things even further by dumping MS Ajax and using a setup like JQuery / JSON / WCF to make the request / response ultra lightweight. However even if you do these things, expecting a sub-second turnaround over the public internet would still be fatal.

    This is why I said in my last post that IMO it's time to rethink this strategy and redesign or realign your expectations of what's reliably achievable.
     

    Attached Files:

  14. Incredible post Joe, very well stated.
     
  15. ok thanks
    i just removed ajax from my site..
     
  16. Agreed!
     

Share This Page