when i type wrong username like this localhost:48890/@mic6pp
i get this error
the correct username is localhost:48890/@mic
the error i get is this
Server Error in '/' Application.
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:
Line 2172: protected void userprofilestatus_DataBound(object sender, EventArgs e)
Line 2173: {
Line 2174: if (string.IsNullOrEmpty(((DataRowView)userprofilestatus.DataItem)["UserVerifyStatus"].ToString()))
Line 2175: {
Line 2176: Control PLNHid = userprofilestatus.FindControl("PLNHid");
code
if (!Page.IsPostBack)
{
if (this.Page.User.Identity.IsAuthenticated)
{
string username32 = this.Page.User.Identity.Name;
GetProfilestatus(username32);
}
}
}
public void GetProfilestatus(string username32)
{
string str = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
string getADPOST = "GetUSERPROmypro";
using (SqlConnection con = new SqlConnection(str))
{
con.Open();
using (SqlCommand cmd = new SqlCommand(getADPOST, con))
{
cmd.CommandType = CommandType.StoredProcedure;
// cmd.Parameters.AddWithValue("@Name", Request.QueryString["Id"].ToString());
// cmd.Parameters.AddWithValue("@FriendUserName", string.IsNullOrEmpty(Request.QueryString["Id"]) ? Page.RouteData.Values["Id"].ToString() : Request.QueryString["Id"].ToString());
cmd.Parameters.AddWithValue("@Email", string.IsNullOrEmpty(Request.QueryString["Id"]) ? Page.RouteData.Values["Id"].ToString() : Request.QueryString["Id"].ToString());
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable ds = new DataTable();
da.Fill(ds);
userprofilestatus.DataSource = ds;
userprofilestatus.DataBind();
protected void userprofilestatus_DataBound(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(((DataRowView)userprofilestatus.DataItem)["UserVerifyStatus"].ToString()))
{
Control PLNHid = userprofilestatus.FindControl("PLNHid");
PLNHid.Visible = false;
}
}
if the user types another user username on url like this localhost:48890/@mic, the records of mic will show on page, but the issue is if the user types wrong url instead of showing code error on page let it do nothing.