AJAX Call Works on LocalHost, doesn't anywhere else

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);
        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?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

badrhinoAuthor Commented:
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.
Aaron JabamaniTechnical ArchitectCommented:
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
badrhinoAuthor Commented:

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.

Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

badrhinoAuthor Commented:
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--
badrhinoAuthor Commented:
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:

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.
badrhinoAuthor Commented:
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?
badrhinoAuthor Commented:
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.
badrhinoAuthor Commented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
badrhinoAuthor Commented:
Only had one response.  That response while appreciated, didn't help me in solving question.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.