【发布时间】:2012-10-09 14:39:55
【问题描述】:
我已经在服务器上上传了一个 web 项目。
虽然它在我进行开发的本地电脑上运行顺利,但它根本没有在服务器上运行。据我所知,空数据集存在问题(从 SQL 数据库中获取数据)。同样,在本地运行 aspx 时,一切正常。我在错误日志中看到的另一个问题是它指向我的本地驱动器“D:...” 它不应该指向服务器地址吗?
错误。
There is no row at position 0.
Exception Details: System.IndexOutOfRangeException: There is no row at position 0.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[IndexOutOfRangeException: There is no row at position 0.]
System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex) +2474798
System.Data.DataRowCollection.get_Item(Int32 index) +21
WEB.Default.Page_Load(Object sender, EventArgs e) in D:\dev\Visual Studio\Temp\WEB\Default.aspx.cs:59
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064
有什么想法吗?我使用 VS2010 的发布工具,它成功上传到服务器。但它不起作用。
我不明白的另一件事是,如果我在页面加载中有 try/catch,为什么网页会发送此错误。如果有错误,它会设置一个带有友好消息的标签。
谢谢。
编辑
这是页面加载代码。
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
Session["FlagOpen"] = false;
var windowsIdentity = WindowsIdentity.GetCurrent();
if (windowsIdentity != null)
{
var userName = windowsIdentity.Name;
userName = Regex.Replace(userName, ".*\\\\(.*)", "$1", RegexOptions.None);
var ds = _objUser.GetRanking(userName);
var ranking = ds.Tables[0].Rows[0][1].ToString();
_objPersona.Ranking = ranking;
_objPersona.UserName = userName;
_objPersona.RealName = ds.Tables[0].Rows[0][0].ToString();
Session["User"] = _objPersona;
LblUserName.Text = ds.Tables[0].Rows[0][0].ToString();
ds = _objUser.GetFAQ(userName);
var cant = ds.Tables[0].Rows.Count;
}
else
{
BtnAbrirBandeja.Enabled = false;
LblUserName.Text = "Not allowed.";
}
}
}
catch (Exception)
{
LblWarnings.Text = "Error. Please contact sysadmin.";
throw;
}
}
编辑 2。
页面继续在本地工作。但不在服务器上。它抛出指向本地文件夹的原始错误(当它已经从服务器上载并运行时)。 DataSet 为空是 Web 无法与 SQL 服务器通信的结果。因此错误。 基本上,它在调试时运行正常,但在服务器上运行不正常。
有什么想法吗?谢谢。
【问题讨论】:
-
没有任何来源,很难分辨。
-
愚蠢的问题,但是可以从服务器访问数据库吗?
-
@PhonicUK 如果需要,我可以向您展示 Page_Load,但由于它(本地)有效,我认为这将是本地/服务器 aspx 内容的更普遍错误。
-
@Jay 我知道来自同一台服务器的其他 webprojects 访问那个特定的 SQL 数据库,所以我假设是的。不过会检查。
-
这个建议很糟糕,抱歉。
标签: c# asp.net visual-studio-2010