Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TailspinSpyworks
{
    public partial class Error : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label_ErrorFrom.Text = Request["Err"].ToString();
            Label_ErrorMessage.Text = Request["InnerErr"].ToString();
        }
    }
}
Posted

1 solution

Request["InnerErr"] is null. you can't call ToString method of null object. it will throw NullReferenceException

you can check null and then call to string method like below
C#
if(Request["Err"]!=null)
  Label_ErrorFrom.Text = Request["Err"].ToString();
if(Request["InnerErr"]!=null)
  Label_ErrorMessage.Text = Request["InnerErr"].ToString();

OR
C#
protected void Page_Load(object sender, EventArgs e)
{
    Label_ErrorFrom.Text = Request["Err"] as string;
    Label_ErrorMessage.Text = Request["InnerErr"] as string;
}
 
Share this answer
 
v2
Comments
Sampath Lokuge 18-Jun-14 9:38am    
+5 :)
DamithSL 18-Jun-14 12:21pm    
Thank you Sampath

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900