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 8380909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:34:38+00:00 2026-06-09T16:34:38+00:00

I am developing an ASP.Net MVC 3 web application. I have a ViewModel public

  • 0

I am developing an ASP.Net MVC 3 web application. I have a ViewModel

public class ViewModelFormPreview
{
    public FormPersonal PersonDetails { get; set; }
    public IList<FormEmployment> Employment { get; set; }
    public FormMembership Membership { get; set; }
}

And a Razor View which accepts this ViewModel

@model Locum.UI.ViewModels.ViewModelFormPreview

<h1 class="sepH_b">Application Preview</h1>

  @Html.Partial("FormPreviewApplication/PersonalDetails", Model.PersonDetails)

  @Html.Partial("FormPreviewApplication/Employment", Model.Employment)

  @Html.Partial("FormPreviewApplication/MembershipDetails", Model.Membership)   

The last part of the View is where my problem is happening.

If Model.Memebership != null then the Partial View, which accepts an Object of type FormMembership, works nicely. However, if Model.Memebership is NULL, I get an error like below

The model item passed into the dictionary is of type
‘Locum.UI.ViewModels.ViewModelFormPreview’, but this dictionary
requires a model item of type ‘Locum.POCO.FormMembership

This is a strange error, because, even if Model.Memebership is NULL, it is still of type FormMembership. So then, why is the error stating I am trying to pass in ViewModelFormPreview when the Object is NULL?

Can anyone help with this?

Thanks.

  • 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-09T16:34:39+00:00Added an answer on June 9, 2026 at 4:34 pm

    As the message says, it is NULL and not EMPTY.
    If you try to use Membership.MyFiels, with membership null, you always get an error.

    To resolve your problem simply initialize your class, with default values in case of NULL, or use an IF to check if it’s NULL or not

    Something like this.

    @if (Model,Membership!=null) {
      @Html.Partial("FormPreviewApplication/MembershipDetails", Model.Membership) 
    }
    else
    {
      @Html.Partial("FormPreviewApplication/MembershipDetails", new FormMembership())     
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an ASP.Net MVC 3 Web application using Razor Views. I have
I have an Asp.Net MVC Web Application that I am developing. I have TeamCity
For the web application (ASP.NET MVC) I'm currently developing, we have the following architecture
I have started developing a full-web application by using the ASP .NET MVC 3
I am developing an ASP.Net MVC 3 Web Application. I have a Razor View
I'm developing an web application using asp.net MVC and jQuery. I have in my
I have just started developing a full-web application by using the ASP .NET MVC
I am developing an ASP.Net MVC 3 Web application with Entity Framework 4.1 and
I am developing an ASP.Net MVC 3 Web application using Entity Framework 4.1 and
I am developing an ASP.Net MVC 3 Web application using Entity Framework 4.1, however,

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.