0

Help! I have to present this website really soon and I dont know what to do. I'm using Ultidev and I can access the website just fine. But when it tries to access the database that's hosted on the same server/computer that the website is being hosted on.. or if my website tries to ping other websites (a feature i built).. i keep getting this error

HTTP Error 404. The requested resource is not found.

Though I can use a "GET" from a different ServiceStack REST API IP which is weird.

This works:

service.getNFLGames = function (season, week, seasonType) {
        if (season && week && seasonType) {
            var deferred = $q.defer();

            $http.get(http://<SAME IP AS THE HOST>/foundationservice + '/nflgame?'
                + 'season=' + season + '&week=' + week + '&seasontype=' + seasonType + '&format=json')

                .success(function (data) {
                    deferred.resolve(data);
                }).error(function () {
                    deferred.reject('There was an error getting NFL game list.');
                });

            return deferred.promise;
        }
    };

this doesn't work (returns 404) .. but this does work locally

[HttpPost]
    public JsonResult GetPlayerMPHTable()
    {
        using (Entities db = new Entities())
        {
            try
            {
                var entries = (from pages in db.foundationPlayerMPHs
                               select pages).ToList();
                return Json(entries);
            }
            catch (Exception ex)
            {
                return Json(null);
            }
        }
    }

This doesn't work neither but again works when i run it locally..returns 404 and i can ping the addresses it's trying to ping if i go into DOS and try myself:

[HttpPost]
    public long PingIP(string ip)
    {
        try
        {
            Ping ping = new Ping();
            PingReply pingResult = ping.Send(ip);

            if (pingResult.Status == 0)
                return pingResult.RoundtripTime;
            else
                return -1;
        }
        catch (Exception ex)
        {
            return -1;
        }
    }

What's also weird is i hosted it before.. and it all worked fine. the one thing i did change was i did a refresh on the database to update a database model. But i mean.. it's hosted on the same friggin computer i dont understand what's going on

here's my connection string as well

<add name="Entities" connectionString="metadata=res://*/Database.Foundation.csdl|res://*/Database.Foundation.ssdl|res://*/Database.Foundation.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=IP HERE;initial catalog=Foundation-NFL;persist security info=True;user id=USERNAMEHERE;password=PASSWORDHERE;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
user1189352
  • 3,628
  • 12
  • 50
  • 90

1 Answers1

0

Try this

 return Json(entries, JsonRequestBehavior.AllowGet);
Douglas
  • 177
  • 11
  • While this code snippet may solve the question, [including an explanation](//meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, as this reduces the readability of both the code and the explanations! – Blue Aug 13 '16 at 08:59