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

  • Home
  • SEARCH
  • 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 7726087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:07:32+00:00 2026-06-01T05:07:32+00:00

Not sure what’s going on here… My controller methods looks like this: [HttpGet] public

  • 0

Not sure what’s going on here…

My controller methods looks like this:

[HttpGet]
public ActionResult RequestAppointment()
{
    var appointmentRequest = new AppointmentRequest
    {
        Stylists = _repository.Stylists // <-- Debugging shows that Stylists IS being populated here
    };

    return View(appointmentRequest);
}

[HttpPost]
public ActionResult RequestAppointment(AppointmentRequest appointmentRequest)
{
    if(ModelState.IsValid)
    {
        // Process...
        return RedirectToAction("Confirmation");
    }
    return View(appointmentRequest);
}

The form looks like this:

@model MyDomain.Models.AppointmentRequest

@using(Html.BeginForm("RequestAppointment", "Appointment" FormMethod.Post))
{
    // This following line throws the exception:
    @Html.DropDownListFor(x => x.Stylist,
        Model.Stylists.Select(x => new SelectListItem{ Text = x.Name, Value = x.Name })))

    <input type="submit" value="Make Request" />
}

The drop down list is populated form with the correct text & values. But when the form is submitted, the exception is thrown. What’s going on?

Stack Trace:

[ArgumentNullException: Value cannot be null.
Parameter name: source]
   System.Linq.Enumerable.Select(IEnumerable`1 source, Func`2 selector) +6396316
   ASP._Page_Views_Appointment_RequestAppointment_cshtml.Execute() in c:\Projects\OasisSalon\OasisSalon.Mvc\Views\Appointment\RequestAppointment.cshtml:9
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +143
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +157
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +384
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +33
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +825460
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +825488
   System.Web.Mvc.Controller.ExecuteCore() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
  • 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-01T05:07:35+00:00Added an answer on June 1, 2026 at 5:07 am

    You must initialize the Stylists property in your POST action if you intend to redisplay the same view:

    [HttpPost]
    public ActionResult RequestAppointment(AppointmentRequest appointmentRequest)
    {
        if(ModelState.IsValid)
        {
            // Process...
            return RedirectToAction("Confirmation");
        }
    
        appointmentRequest.Stylists = _repository.Stylists;
        return View(appointmentRequest);
    }
    

    You get a NRE because you are attempting to render a DropDownList in your view using Model.Stylists in your view but obviously this property is null after the POST action is executed as you never assigned it and its value is not populated automatically because all that’s sent into the POST request is the selected value of the dropdown list (the Stylist property).

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

Sidebar

Related Questions

Not sure what exactly is going on here, but seems like in .NET 1.1
Not sure what's going on here. I have a DateTime object, and when I
Not sure what's going on here, but in my Rails 3 application, I type
Not sure if i'm taking the right approach here. I've set up various controller
Not sure whether this should be asked here or on another site such as
Not sure if this is even possible but I would like to add a
Not sure if this really belongs here, so please move it if it doesn't.
Not sure what I'm missing here but this code runs without any error message,
Not sure how to frame this one, so here goes... I have a need
Not sure if this is possible or if I'm expressing correctly what I'm looking

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.