This question already has an answer here:

I am trying to avoid using Html.CheckBoxFor in MVC 5 because of the extra hidden input that is added into the DOM. Reason being i am using a template and the extra input kills the lovely css'd checkbox styling.

when doing this:

<input type="checkbox" 
id="@Html.IdFor(m => m.RememberMe)" 
name="@Html.NameFor(m => m.RememberMe)" 
value="true" checked="@(Model.RememberMe ? " checked" : String.Empty)" />

This question already has an answer here:

I am trying to add values to dictionary. Here is my code :-

public class EmpModel
{
    ....
    public Dictionary<String, String> EmpColumns { get; set; }
}

Controller

EmpModel model = new EmpModel();
model.EmpColumns.Add("one", "1"); // It gives error here

An exception of type

System.NullReferenceException

Why i am getting this error? How to solve this?

This question already has an answer here:

i am getting a strange error in a Web applicaton mvc project, in razor view i am getting NullReferenceException even object is not null.

here is link of screenshot of error. [screenshot of error] http://i.stack.imgur.com/eL8HQ.png

Things those i already tried:

  1. Cleaned/Rebuild solution and project.
  2. Deleted Temporary ASP.NET Files.
  3. Deleted View, Renamed View.
  4. Deleted Obj folder.
  5. Changed build config to Debug/Release.

None of these helped.

Please help me to solve this.

This question already has an answer here:

creating a login form however when comparing the username and password in database to allow access am ending up with this error.

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

at this line,

SqlCommand cmd3 = new SqlCommand("Select id,Username,
                                  Password from User_data 
                                  where Username='"+UserName.Text.Trim()+"'",con);

below is my code,

protected void button1_click(Object sender, EventArgs e)
{
    SqlCommand cmd3 = new SqlCommand("Select id,Username,Password from User_data where Username='"+UserName.Text.Trim()+"'",con);

    dr = cmd3.ExecuteReader();
    dr.Read();

    string id = dr[0].ToString();
    string un=dr[1].ToString();
    string pwd= dr[2].ToString();

    dr.Close();

    con.Close();
}

This question already has an answer here:

I am using ExecuteScalar(). So It will return single column.

If the record is exist, It's not showing any error. If record is not found. It throws System.NullReferenceException on the following line

cmd.CommandText = "select top 1 UserID from [HQWebMatajer].[dbo].[SecurityUserDetails] where [UserID]=@UserID and [ReportName]='TotalSales';";
cmd.Parameters.AddWithValue("@UserID", ddlSecurityUser.SelectedValue);

con.Open();
string dataExist = null;
dataExist= cmd.ExecuteScalar().ToString(); // Error

This question already has an answer here:

I am seeing an intermittent issue that we cannot reliably reproduce in ASP.NET Identity (MVC 5.2.3).

The top of the stack trace suggests the issue is occurring on retrieving the password hash from the database:

System.NullReferenceException: Object reference not set to an instance of an object.
    at Portal.Web.Identity.IdentityStorageContext.<>c.<get_PasswordHash>b__6_0()
    at System.Threading.Tasks.Task`1.InnerInvoke()
    at System.Threading.Tasks.Task.Execute()

SQL server isn't logging any errors. Trying the action again succeeds. We have noticed it occuring on both live and pre-prod.

IdentityStorageContext.cs extract:

public Task<string> PasswordHash
{
     get { return Task<string>.Factory.StartNew(() => identityUser.PasswordHash); }
}

Any ideas?

This question already has an answer here:

Well i have this in the PostController:

public ActionResult Index()
{
 List<Post> Posts = PostLogic.GetPosts(db);
 return View(Posts);
}

public ActionResult User()
{
 List<Post> Posts = PostLogic.GetPosts(db);
 return View(Posts);
}   

Index and User are doing the same things, the problem is that i'm getting System.NullReferenceException from User. Here is my working Index view:

@model IEnumerable<ProjectX.Models.Post>
 @foreach (var item in Model)
 {
 @item.post
 }

Here is my non working User view:

 @model IEnumerable<ProjectX.Models.Post>

    @foreach (var item in Model)
    {
    @item.post
    }

Why am i getting NullReferenceException from the Userview when the indexview works perfect?

This question already has an answer here:

I made a user control having 4 dropdown list and I want to get their selected value in .aspx where I am referring this User Control. I use multiple options to get the selected value of ddl from User Control but each time its giving error " Object reference not set to an instance of Object". Here is code I am using

In your WebUserControl (user control) code-behind file, you could have something like this:

In WebUserControl (user control) code-behind file

public string DropDownSelectedValue
{
    get
    {
       return dropDown.SelectedValue;
    }
}

In web page where I am using that user control // Assuming I have defined usercontrol with the 'yourUserControl' ID

string selectedValue = yourUserControl.DropDownSelectedValue;

This question already has an answer here:

Line 19:     
static BalloonShopConnectionString1()

Line 20:  
   {

Line 21:
         dbConnectionString = ConfigurationManager.ConnectionStrings["BalloonShopConnection"].ConnectionString;

Line 22:
         dbProviderName = ConfigurationManager.ConnectionStrings["BalloonShopConnection"].ProviderName;

Line 23:         productsPerPage = System.Int32.Parse(ConfigurationManager.AppSettings["ProductsPerPage"]);

Line 21 Error

This question already has an answer here:

I keep getting this errro while running my web site after registration

response.redirect("main.aspx")

protected void CheckFriendshipStatus() { if (Object.Equals(Session["UserId"].ToString(), Session["CurrentProfileId"].ToString())) {

pic

This question already has an answer here:

 public static string GetHRPaidTimeOffConnectionString()
     {
         return ConfigurationManager.ConnectionStrings[HRPAIDTIMEOFF_CONNSTRING_KEY].ConnectionString;
     }

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.