0

So, here's my situation:

Project 1 : C# web service project that hits the DB and has a bunch of methods
Project 2 : Angular JS Web App that uses $http to call the said web service methods

Now, I've deployed both the web service and the web app to my local IIS and everything's working great, locally. Page loads happen and the data is returned from the database and appropriately displayed.
Now comes the problem. When someone tries to access the application from their machine - the code that calls the web service methods give me the internal server error. The strange part is, the web services can be viewed (not invoked) from the other machines.

Scenario:

I can access the following:
Web service : http://DataAccessService/DataAccessService.asmx
Angular App : http://ReportzApp/#/ The landing page of the "ReportzApp" internally calls the web service using $http and that works flawlessly.

Others can access:
Web service : http://DataAccessService/DataAccessService.asmx (only see the list of service methods but can't invoke)
Angular App : http://ReportzApp/#/ But, I get the internal server error in the landing page.

I have also enabled CORS on the web-service side as well:

<httpProtocol>
    <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
    </customHeaders>
</httpProtocol>

Also, here's a sample function that I use to call my web-service code:

getData: function () {
                promise = $http({
                    method: 'POST',
                    url: "http://<myMachineName>/DataAccessService/DataAccessService.asmx/GetData",
                    data: "{}",
                    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
                }).then(function (response) {
                    console.log(response);
                    return response;
                }),
                function (response) {
                    // failed
                    console.log('failed ' + response);
                };

                // Return the promise to the controller
                return promise;
            }

What am I missing?

Barry Michael Doyle
  • 9,333
  • 30
  • 83
  • 143
Nabakamal Das
  • 89
  • 2
  • 7
  • Internal server error indicates of some application exception, try to check server logs maybe and see where it comes from? – Ben Bracha Oct 27 '16 at 13:29
  • You could put some logs in your webservice if its being hit or not when someone access it from their machine. – Akshay Oct 27 '16 at 14:08
  • url: "http:///DataAccessService/DataAccessSer.... Why would others have access to your machine??? – Akshay Oct 27 '16 at 14:09
  • @Sak : Well, I've published the Web service on my local IIS so they can view all the available methods. Plus, when they want to access the application that's hosted on my machine then I wanted them to have the access. – Nabakamal Das Oct 27 '16 at 16:27
  • @BenBracha: The code never reaches the respective web service method when the application is being accessed from another machine. Eg. A colleague's machine. Plus, when I browse the pages, I don't get any such internal server errors. Works flawlessly :( – Nabakamal Das Oct 27 '16 at 16:30
  • Got it. A colleague machine not being able to reach your server may be some firewall / port has to be opened issue. But what is strange is that 500 is returned (and not, for example, 404). – Ben Bracha Oct 27 '16 at 17:00
  • @BenBracha: Yeah. Are there any pointers that I can check for ? 'Cuz, this is driving me nuts :( – Nabakamal Das Oct 27 '16 at 17:25
  • So, I got this working. I had to enable Get and Post on the web services side for this to work. Like this : ` ` The link : http://stackoverflow.com/questions/654099/how-do-i-fix-a-request-format-is-unrecognized-for-url-error-in-a-web-servic helped me. – Nabakamal Das Oct 28 '16 at 08:22

0 Answers0