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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:50:50+00:00 2026-06-01T17:50:50+00:00

I’m newbie to MVC architecture.When I’m trying to update, its showing error ,Its totally

  • 0

I’m newbie to MVC architecture.When I’m trying to update, its showing error ,Its totally strange but the data is updating.

The model item passed into the dictionary is of type ‘CMS.Domain.Models.Site’, but this dictionary requires a model item of type ‘CMS.Web.ViewModels.SiteModel’.’.

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.InvalidOperationException: The model item passed into the dictionary is of type ‘CMS.Web.ViewModels.SiteModel’, but this dictionary requires a model item of type ‘System.Collections.Generic.IEnumerable`1[CMS.Web.ViewModels.SiteModel]’.

My code looks like:

ViewModels:

namespace CMS.Web.ViewModels
{
    public class SiteModel
    {

        public SiteModel()
        {
            SiteStatus = new List<SelectListItem>();
        }

        [Key]
        public int ID { get; set; }

        [Required(ErrorMessage = "Site Name is required")]
        [Display(Name = "Site Name")]
        public string Title { get; set; }


        [Display(Name = "Require Login")]
        public bool RequiresLogin { get; set; }

        [Display(Name = "Force HTTPS")]
        public bool ForceHTTPS { get; set; }

        [Display(Name = "Enable Approval")]
        public bool Approval { get; set; }

        [AllowHtml]
        public IList<SelectListItem> SiteStatus { get; set; }

        public bool Deleted { get; set; }

        public string CreatedBy { get; set; }

        public DateTime CreatedOn
        {
            get { return _createdOn; }
            set { _createdOn = value; }
        }
        private DateTime _createdOn = DateTime.Now;

        public string LastUpdatedBy { get; set; }

        public DateTime LastUpdatedOn  
        {
            get { return _lastUpdatedOn; }
            set { _lastUpdatedOn = value; }
        }
        private DateTime _lastUpdatedOn = DateTime.Now;

        [Display(Name = "Site State")]
        public string SiteState { get; set; }

    }
}

Model:

namespace CMS.Domain.Models
{
    public partial class Site : Model
    {

        public string Title { get; set; }
        public bool Approval { get; set; }
        public bool RequiresLogin { get; set; }
        public bool ForceHTTPS { get; set; }
        public virtual string SiteStatus { get; set; }
        public bool Deleted { get; set; }

    }
}

Controller:

 public ActionResult Index()
        {
            var _sites = _siterepository.FindAll();
            return View(_sites);
        }

        public ActionResult Add()
        {
            var model = new SiteModel();
            var _SiteStatus = _siterepository.GetSiteStatus();
            foreach (var _sitestatus in _SiteStatus)
            {
                model.SiteStatus.Add(new SelectListItem()
                { 
                    Text = _sitestatus.StatusName, 
                    Value = _sitestatus.StatusName.ToString()
                });

            }
            return View(model);
        }

        [HttpPost]
        public ActionResult Add(SiteModel _sitemodel)
        {
            var model = _sitemodel.ToEntity();
            _siterepository.Add(model);
            return View(model);
        }

        public ActionResult Edit(int id)
        {
            var model = new SiteModel();
            var Site = _siterepository.Find(id);
            model = Site.ToModel();
            var _SiteStatus = _siterepository.GetSiteStatus();

            foreach (var _sitestatus in _SiteStatus)
            {
                model.SiteStatus.Add(new SelectListItem()
                {
                    Text = _sitestatus.StatusName,
                    Value = _sitestatus.StatusName.ToString(),
                    Selected = _sitestatus.StatusName == Site.SiteStatus
                });

            }

            return View(model);
        }

        [HttpPost]
        public ActionResult Edit(SiteModel _sitemodel)
        {
            var model = _sitemodel.ToEntity();
            _siterepository.Update(model);
            return View(model);
        }

I’m struggling to resolve this , please help.

  • 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-01T17:50:51+00:00Added an answer on June 1, 2026 at 5:50 pm

    Check your View’s model declaration. It is expecting an enumerable list (IEnumerable<CMS.Web.ViewModels.SiteModel>), but you are passing it a single instance of CMS.Web.ViewModels.SiteModel

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

Sidebar

Related Questions

I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:

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.