读书人

菜蛋 引用有关问题

发布时间: 2012-04-14 17:14:21 作者: rapoo

菜蛋求助 引用问题
未将对象引用设置到对象的实例。

说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。

源错误:


行 17: {
行 18: string BlogID = "i";
行 19: if (Request["BlogID"].ToString() =="i")
行 20: {
行 21:

源文件: e:\Yan' Blog\Blog.aspx.cs 行: 19

堆栈跟踪:


[NullReferenceException: 未将对象引用设置到对象的实例。]
Module_Blog_PersonInfo.Page_Load(Object sender, EventArgs e) in e:\Yan' Blog\Blog.aspx.cs:19
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.1





本人菜蛋一枚,求大大门指导,不胜感激

[解决办法]
if(Request["BlogID"]!=null)
{
if (Request["BlogID"].ToString() =="i")
{}
}
[解决办法]
18: string BlogID = "i";
行 19: if (Request["BlogID"].ToString() =="i"

Request 是取得客户端浏览器通过post或 get方式传过来的数据,你 BlogID 是string类型 你这么写似乎没意义!

你的Request["BlogID"] 只能取到空值 即null 你到可以这么写:
if (Request["BlogID"] == null)
{..........}

读书人网 >asp.net

热点推荐