Showing posts with label calls. Show all posts
Showing posts with label calls. Show all posts

Wednesday, March 28, 2012

Very weird error. Ajax controls call default.aspx

I have a few pages in my site... and for some reason, if there's any ajax controls on the page, it calls default.aspx and runs the code every time any aspx page with an ajax control exists on it. Problem is, default.aspx resets my session variables.

Why does Ajax call the default.aspx page code? It only runs the CS file... it doesn't actually show the default.aspx page.

I doubt it calls it. Do you have a component in your site somewhere that's got a url of "/" attached to it somewhere, and that's invoking the default page?


it only seemed to only happen when I have Certain Ajax controls on the page. Note, it only does it with Internet Explorer 6 and 7. Firefox seems to be fine.

For example, I have a collapsible PAnel in each row of a Gridview. That is in an UpdatePanel. When the Gridview is populated (and I have a breakpoint on the default.aspx.cs file), it goes through that code. Well, I set my session variables on that page, so in essence it resets them.

It seems like it does this AFTER the page is loaded, because the labels that show content based on those session variables aren't updated until I go to a new page.

It only does this when I have a collapsible panel in IE. The panel is set to collapsed.


Actually, it appears that AJAX is clearing the Session Variables. I don't know where it's doing this, though.

Wednesday, March 21, 2012

Web Service calls .NET 2.0

I have an ASP.NET application in .NET 1.1 that makes a web service call using the Begin{WebMethod} call and then returns to the page and redirects to another page. The Async callback is returned later when this is done and I log any errors that this web method call may have had to the event log. The web page does not wait for the response because it's role is to fire it off and then go on. I am trying to move to .NET 2.0 and have an issue where the Async call for 2.0 will not allow me to redirect until the web service has completed. I do not need a response from my web service and would like to move on to another web page. I basically have switched to making this a synchronous call as how 2.0 is handling it is synchronous.

Thanks for any and all help.

Hello Mladinichs,

check out the Ajax video that shows how to use client side Async call back.

http://www.asp.net/learn/ajax-videos/video-79.aspx

I hope it helps.


Client side is not really what I'm looking for. The button click is gathering up info from the screen, performing a save operation and then kicking off an async process. Any thoughts?


Hi,

If your wanting to do this on the client side, does this work?

function DoSave(){

YourSavingService.SaveData()

document.location.href = "yourNextURL.aspx"

}

Cheers Si


This application is an existing application in production and I'd rather not re-write this entire functionality to be client-side. Is there no way to do this server-side?


Hi,

I suggest using a separate thread to run the task which is currently running on the main thread of the web service that halts it form return soon.

For instance, say your web service is like this now:

void fun() { doSomething(); }

change it to:

void fun() {Thread thrd = new Thread(new thredInfo(doSomeThing); thrd.Start(); }

Web Service Calls From AJAX - No Cross Domain? NOT!

The AJAX 2.0 documentation states that Web Services can not be called "cross domain". This is a browser side restriction, so says Microsoft support. While one might disagree, I think of cross-domain as meaning between machines on different internet domains (i.e. machine1.bigcompany.com and machine2.bigcompany.com are on the same domain while machine3.yourcompany.com is on a different domain). This is not what Microsoft means. The use of the term "cross domain" in the documentation means that machine1.bigcompany.com and machine2.bigcompany.com are on different domains and AJAX web service calls between them can not be made successfully . At least this is what MS support tells me. I have found however that I can create a page on machine1.bigcompany.com and call a web service on machine2.bigcompany.com. To do this requires that four conditions be true:

1) You use IE 7 as your browser;

2) do not select the "inline script" option on the scriptmanager/services attribute

3)call set_path in your javascript to set the endpoint of the web service to machine2;

4) both machine1.bigcompany.com and machine2.bigcompany.com are defined as within the INTRANET ZONE in IE 7.

Firefox has no option like "intranet zones" so I have been unable to get this to work with Firefox. I am still working on this.

By the way if you have the same AJAX web page deployed on two different machines (meeting the conditions discribed above) with AJAX "PageMethods" defined, you can call set_path on the

PageMethod using Javascript and make calls between machines for PageMethods also.

Hope This Helps

dlr

You can implment this for Cross Domain issue:
http://weblogs.asp.net/rashid/archive/2007/09/28/implement-jsonp-in-your-asp-net-application.aspx