Solved

AJAX Call Works on LocalHost, doesn't anywhere else

Posted on 2014-02-28
9
1,110 Views
Last Modified: 2014-03-06
I've inherited a website that I'm migrating to a new server (Windows Server 2003 to Windows Server 2012).  Everything seems to work after the migration except one of my ajax calls.  Below is the code that fails:

  var encodedInput = $.toJSON(input);
$.ajax({
        type: "POST",
        url: "Sim.svc/revenue",
        contentType: "application/json; charset=utf-8",
        data: encodedInput,
        dataType: "json",
        error: fnError,
        success: ... 

Open in new window


The sim.svc code is:
<%@ ServiceHost Language="C#" Debug="true" Service="W.Services.Sim" Factory="W.Services.AppServiceHostFactory" %>

Open in new window


W.Services.SIm is a dll.

This ajax call works if I'm on the production server and use http://localhost:80/page.aspx.  However, if I try and access the website (on the production or any where else) using www.domainName/page.aspx the ajax call fails.  

The only thing that indicates that the call has failed is a custom message that says: 'loading failed'.  When I use firebug, it says that sim.svc/renenue is  not found (404)

Any ideas?

Thanks!
0
Comment
Question by:badrhino
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
9 Comments
 
LVL 1

Author Comment

by:badrhino
ID: 39896277
I've made a little progress, because I have multiple bindings to this site (e.g. http://domainName.com and http://www.domainName.com) I have to add multipleSiteBindingsEnabled="true"   to the    <serviceHostingEnvironment /> element in the web.config file.

<serviceHostingEnvironment  multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" /> 

Open in new window


Now,  I'm getting an error that says 'the input string is not in a correct format'.  I get this error if I access it via the domain name or localhost.
0
 
LVL 25

Expert Comment

by:apeter
ID: 39897145
Using the developer tools you check the request going in. Check the request is fine.


Had a chance  to look at asp.net web API ? http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api
0
 
LVL 1

Author Comment

by:badrhino
ID: 39897208
Apeter,

Thanks for the response.  I have hesitated checking the response as I wouldn't think that it would change by simply changing from localhost to domainName.  I will check that now with firebug.  I need to stress that the application workd before I added the multiple bindings element when I used http://localhost:....) but it didn't work if I use www.domainName.com (on production server) .  Once I added the multiple bindings element neither site works, but I don't get an error in the event viewer.

Thanks!
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 1

Author Comment

by:badrhino
ID: 39897219
I don't know if this helps, but the response from firebug is:

'InternalServerError'</P><P><B>Details: </B>Input string was not in a correct format.</P><!-- Padding xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx--
0
 
LVL 1

Author Comment

by:badrhino
ID: 39897240
Ok.  I compared the response via a 'compare document' in word (inputs are 2 pages long).  The only difference between the website that is working and the website that is not working is on the website that is not working the LastModified input is:
"LastModified": "/Date(21600000-0600)/"

Open in new window


On the website that is working, the lastModified input is:
/Date(18000000-0500)/

Open in new window


I'm not sure why these are different so I'm going to look into the code....But it looks like it is valid.
0
 
LVL 1

Author Comment

by:badrhino
ID: 39897270
This might be the problem.  On the New server, in the response headers it has:
Content-Type:      text/html

In the old server (that works) it has:
Content-Type: application/json; charset=utf-8

any idea's how to fix it?
0
 
LVL 1

Author Comment

by:badrhino
ID: 39897337
It looks like the Conet-Type is text/html because the error is being returned as such.  Doesn't look like that is what is causing the problem.
0
 
LVL 1

Accepted Solution

by:
badrhino earned 0 total points
ID: 39897596
Finally got it.  It had to do with the fact that I had multiple bindings to the site.  Deleted all but one and everything worked.  Never got the multiple bindings to work, but I really only need one.
0
 
LVL 1

Author Closing Comment

by:badrhino
ID: 39908834
Only had one response.  That response while appreciated, didn't help me in solving question.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

740 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