[英]“HTTP Error 404. The requested resource is not found.” when website tries to access database or any other site
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.
我正在使用Ultidev,并且可以正常访问网站。 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
但是,当它尝试访问托管在与该网站托管在同一台服务器/计算机上的数据库时..或者如果我的网站尝试对其他网站执行ping操作(我构建的功能)..我一直收到此错误
HTTP Error 404. The requested resource is not found.
HTTP错误404。找不到请求的资源。
Though I can use a "GET" from a different ServiceStack REST API IP which is weird. 尽管我可以使用来自另一个ServiceStack REST API IP的“ GET”,这很奇怪。
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 这不起作用(返回404)..但这在本地确实起作用
[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: 这既不起作用,但是当我在本地运行它时也再次起作用。返回404,如果我进入DOS并尝试自己,我可以ping它试图ping的地址:
[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="data source=IP HERE;initial catalog=Foundation-NFL;persist security info=True;user id=USERNAMEHERE;password=PASSWORDHERE;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
尝试这个
return Json(entries, JsonRequestBehavior.AllowGet);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.