views:

17

answers:

1

I am trying to post some data from one local asp.net mvc site to another but am unable to do so. I execute the following post on site A

// tried this and it didn't work      
//$.post("http://localhost/PlatformPortal/Buyers/Account/SignIn",
//{sign:authHeader})

// Currently trying this                  
    $.ajax({
             url: "http://localhost/PlatformPortal/Buyers/Account/SignIn",
             data: authHeader,
             type: "POST",
             success: function() { alert('Success!'); }
          })

I expected the POST "SignIn" action in the AccountController for SiteB to be hit, but it isn't. However, I do get the "Success!" popup message when I execute the post by clicking the link that the jquery snippet pasted above is wired to. Am I missing something ?

A: 

Since $.ajax() uses XMLHttpRequest, it is subject to XHR's cross-domain restriction.

Are your SiteA and SiteB on different hosts/ports? If so, you're seeing the expected behavior.

Dave Ward
Hi Dave, thanks for getting back to me.Currently for testing purposes both my sites are on my local dev. box (localhost). So they are something like http://localhost/SiteA and http://localhost/SiteB
Cranialsurge
If you run Fiddler to monitor the traffic, are you seeing anything returned from SiteB?
David Hoerster
I get a perfect return (200) from the server in Fiddler with the following info.Uri - http://localhost/PlatformPortal/Buyers/Account/SignInRequestHeadersUser-Agent: FiddlerHost: localhostContent-Length: 0Data: TestIs the "data" variable that is part of the jQuery ajax syntax the POST body or the header ?
Cranialsurge
My bad, it was in fact working fine, a Visual Studio was unable to catch the post on account of a pending restart and it couldn't load the debugging symbols right. The post is working just fine. Thanks a ton for your patience.
Cranialsurge