Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8826995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:16:40+00:00 2026-06-14T07:16:40+00:00

I have not changed my code, which used to work, I even clarified this

  • 0

I have not changed my code, which used to work, I even clarified this with an earlier build of the project. However, I now get this error:

The parameters dictionary contains a null entry for parameter ‘recipeID’ of non-nullable type ‘System.Int32’ for method ‘System.Web.Mvc.ActionResult Create(Int32, BareCupboard.Models.RecipeStep)’ in ‘BareCupboard.Controllers.RecipeStepController’. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters

My code is:

[HttpPost]
    public ActionResult Create(int recipeID, RecipeStep newRecipeStep)
    {
        try
        {
            var recipe = db.Recipes.Single(r => r.recipeID == recipeID);
            recipe.RecipieSteps.Add(newRecipeStep);
            db.SaveChanges();
            return RedirectToAction("Index", "Recipe");
        }
        catch
        {
            return View();
        }
    }

I tried: int? recipeID, but this fails to work.
Any ideas what might have happened as all I can see is mysticism at play here!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:16:41+00:00Added an answer on June 14, 2026 at 7:16 am

    Check your view code for the order of the parameters. The model binder needs it come in proper order. It is very easy to make mistake there.

    Update

    Here one way of resolving this. Create a view model as below:

        public class RecipeViewModel
        {
           public int RecipeId { get; set; }
           public RecipeStep RecipeStep { get; set; }
        }
    

    In the controller you will have the following:

        public ActionResult Create()
        {
            var recipeId = 10 // however you want to select that Id
    
            var recipeViewModel = new RecipeViewModel {RecipeId = 10}
    
            return View(recipeViewModel);
        }
    
      [HttpPost]
      public ActionResult Create(int recipeID, RecipeStep newRecipeStep)
      {
         //your code
      }
    

    In the view you can do the following:

    @model MvcApplication3.Models.RecipeViewModel
    
    @using (Html.BeginForm(null,null,FormMethod.Post))
    {
    
     <div>
        <p>@Html.HiddenFor(x=>x.RecipeId) </p>
        <p>@Html.TextBox("RecipeStepData1")</p>
         <p>@Html.TextBox("RecipeStepData2")</p>
        <p>@Html.TextBox("RecipeStepData3")</p>
    </div>
    <input type="submit" value="Submit"  id="btn" /> 
    }
    

    Notice the order. I put the id first and then rest of the recipe step data so it gets bind properly.

    For the begin form, You dont have to specify action and controller as you are doing the post on the same page. It doesnt hurt if you put there.

    Hope this helps… 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have not changed any of the configuration options for sessions in my php.ini.
I have a given XML document (structure can not be changed) and want to
If an entities properties have changed in a controller action and Update/SaveChanges is not
Did not upgrade anything, nothing should have changed, but I may have a silly
I have not had to do something like this in the past and am
I have not started creating the code so I don't have anything to show,
So I have this VB.Net Application. It uses SQL Server database, for which it
I have a C++ application which used Mutex, Events,Semaphores for synchronization. While hosted in
I have a multithreaded Java code in which: several threads read stateful objects from
I have an open source project which I had been actively developing JStock -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.