在登出Fom用户端时我遇到了错误。 [英] In Logging Out Fom User Side I Am Getting Following Error.

查看:60
本文介绍了在登出Fom用户端时我遇到了错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对象引用未设置为对象的实例。

描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。



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



源错误:

  protected   void  Page_Load( object  sender,EventArgs e)
{
if (!IsPostBack)
{
this 。 ViewState [ vs] = 0 ;
obj.field = Request.QueryString [ field]。ToString( );
obj.functionname = Request.QueryString [ function]的ToString();
DataList1.DataSource = obj.get_desiredjobs();
DataList1.DataBind();
}
pos =( int this .ViewState [ vs];

}

解决方案

obj null ,或者查询字符串不包含字段参数。



Request.QueryString 集合的索引器已经返回字符串;没有必要在返回值上调用 .ToString()

 obj.field = Request.QueryString [  field]; 
obj.functionname = Request.QueryString [ function];


Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.ViewState["vs"] = 0;
             obj.field = Request.QueryString["field"].ToString();
            obj.functionname = Request.QueryString["function"].ToString();
            DataList1.DataSource = obj.get_desiredjobs();
            DataList1.DataBind();
        }
        pos = (int)this.ViewState["vs"];
       
    }

解决方案

Either obj is null, or the query-string doesn't contain the field parameter.

The indexer of the Request.QueryString collection already returns a string; there's no need to call .ToString() on the returned value:

obj.field = Request.QueryString["field"];
obj.functionname = Request.QueryString["function"];


这篇关于在登出Fom用户端时我遇到了错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆