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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:43:17+00:00 2026-05-16T10:43:17+00:00

Server Error in ‘/’ Application. The model item passed into the dictionary is of

  • 0

Server Error in ‘/’ Application.

The model item passed into the dictionary is of type ‘Develosoft4.Models.Cita’, but this dictionary requires a model item of type ‘Develosoft4.Models.CitaFormViewModel’.

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 ‘Develosoft4.Models.Cita’, but this dictionary requires a model item of type ‘Develosoft4.Models.CitaFormViewModel’.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

This is the Create.aspx that throws the error:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Develosoft4.Models.CitaFormViewModel>" %>
    <h2>Create</h2>

    <% using (Html.BeginForm()) {%>
        <%: Html.ValidationSummary(true) %>

        <fieldset>
            <legend></legend>
            
            
            <div class="editor-label">
                <%: Html.LabelFor(model => model.Cita.materia)%>
            </div>
            <div class="editor-field">
            
                <%: Html.DropDownListFor(model => model.Cita.materia, Model.Materias)%>
                <%: Html.ValidationMessageFor(model => model.Cita.materia)%>
            </div>
            
            <div class="editor-label">
                <%: Html.LabelFor(model => model.Cita.cubiculo)%>
            </div>
            <div class="editor-field">
                <%: Html.DropDownListFor(model => model.Cita.cubiculo, Model.Cubiculos)%>
                <%: Html.ValidationMessageFor(model => model.Cita.cubiculo)%>
            </div>
            
            <div class="editor-label">
                <%: Html.LabelFor(model => model.Cita.profesor)%>
            </div>
            <div class="editor-field">
                <%: Html.DropDownListFor(model => model.Cita.profesor, Model.Profesores)%>
                <%: Html.ValidationMessageFor(model => model.Cita.profesor)%>
            </div>
            
            <div class="editor-label">
                <%: Html.LabelFor(model => model.Cita.fecha)%>
            </div>
            <div class="editor-field">
                
                <%: Html.ValidationMessageFor(model => model.Cita.fecha)%>
                    <form>
   <input type="text" name="fecha" id="campofecha">
</form>
            </div>
            
            <div class="editor-label">
                <%: Html.LabelFor(model => model.Cita.horaInicio)%>
            </div>
            <div class="editor-field">
                <%: Html.TextBoxFor(model => model.Cita.horaInicio)%>
                <%: Html.ValidationMessageFor(model => model.Cita.horaInicio)%>
            </div>
            
            <div class="editor-label">
                <%: Html.LabelFor(model => model.Cita.horaFinal)%>
            </div>
            <div class="editor-field">
                <%: Html.TextBoxFor(model => model.Cita.horaFinal)%>
                <%: Html.ValidationMessageFor(model => model.Cita.horaFinal)%>
            </div>
            
            <p>
                <input type="submit" value="Create" />
            </p>
        </fieldset>

    <% } %>

    <div>
        <%: Html.ActionLink("Back to List", "Index") %>
    </div>

This is CitaFormViewModel.cs

using System.Web.Mvc;

namespace Develosoft4.Models
{
    public class CitaFormViewModel
    {
        private static CubiculoRepository cubiculosRepository = new CubiculoRepository();
        private static MateriaRepository materiasRepository = new MateriaRepository();
        private static ProfesorRepository profesorRepository = new ProfesorRepository();

    // Properties
        public Cita Cita { get; private set; }
        public SelectList Cubiculos { get; private set; }
        public SelectList Materias { get; private set; }
        public SelectList Profesores { get; private set; }
    // Constructor
        public CitaFormViewModel(Cita cita)
        {
            Cita = cita;
            Cubiculos = new SelectList(cubiculosRepository.FindAllCubiculos(),"id","nombre", cita.cubiculo);
            Materias = new SelectList(materiasRepository.FindAllMaterias(), "id", "nombre", cita.materia);
            Profesores = new SelectList(profesorRepository.FindAllProfesores(), "id", "nombre", cita.profesor);
        }
    }
}

CitaController.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Develosoft4.Models;


namespace Develosoft4.Controllers
{
    public class CitaController : Controller
    {
        CitaRepository repository = new CitaRepository();

        //
        // GET: /Cita/
       [Authorize (Roles= "director")]
       public ActionResult Index(int page = 0)
        {
            const int pageSize = 10;

            var citas = repository.FindAllCitas();
            var paginatedCita = new PaginatedList<Cita>(citas,page,pageSize);
            return View(paginatedCita);
        }
        //
        // GET: /Cita/Details/2

        public ActionResult Details(int id)
        {
            Cita cita = repository.GetCita(id);

            if (cita == null)
                return View("NotFound");
            else
                return View("Details", cita);
        }
        //
        // GET: /Cita/Edit/2

        public ActionResult Edit(int id)
        {
            Cita cita = repository.GetCita(id);
            CitaFormViewModel viewModel = new CitaFormViewModel(cita);
            return View(viewModel);
        }

        //
        // POST: /Cita/Edit/2
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Edit(int id, FormCollection formValues)
        {
            Cita cita = repository.GetCita(id);

            try
            {
                UpdateModel(cita);
                repository.Save();
                return RedirectToAction("Details", new { id = cita.id });
            }
            catch
            {
                //ModelState.AddRuleViolations(materia.GetRuleViolations());

                return View(cita);
            }
        }

        //
        // GET: /Cita/Create
        public ActionResult Create()
        {
           Cita cita = new Cita();
            return View( new CitaFormViewModel( cita));
        }
        //
        // POST: /Cita/Create

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create(Cita cita)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    repository.Add(cita);
                    repository.Save();
                   return RedirectToAction("Details", new { id = cita.id });
                }
                catch
                {
                    //ModelState.AddRuleViolations(materia.GetRuleViolations());
                }
            }

            return View(cita);
        }

        //
        // HTTP GET: /Cita/Delete/1

        public ActionResult Delete(int id)
        {
            Cita cita = repository.GetCita(id);

            if (cita == null)
                return View("NotFound");
            else
                return View();
        }

        // actitud
        // HTTP POST: /Cita/Delete/1

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Delete(int id, string confirmButton)
        {
            Cita cita = repository.GetCita(id);

            if (cita == null)
                return View("NotFound");

            repository.Delete(cita);
            repository.Save();

            return View("Deleted");
        }
    }
}
  • 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-05-16T10:43:18+00:00Added an answer on May 16, 2026 at 10:43 am

    Your trying to pass your model an object of type Develosoft4.Models.Cita when it is expecting an object of type Develosoft4.Models.CitaFormViewModel.

    You probably have a strongly typed view so you need to pass it the type it is expecting.

    Check your controller when you should have something like this at the end:

    return View(new Develosoft4.Models.CitaFormViewModel()
        {
            // initializers
        });
    

    No idea what you code actually looks like so this is stab in the dark 🙂

    EDIT: Based on the code you added, it looks like your Post version of Create is returning the wrong type to the view.

    You are doing this:

    return View(cita); 
    

    When your Create view is expecting a CitaFormViewModel so you should probably be doing:

    return View(new CitaFormViewModel(cita));
    

    Just lke you did in the Get version of the Create view.

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

Sidebar

Related Questions

Server Error in '/' Application. i tried all the things but im unable to
I tried it but I am getting this error: Server Error in '/' Application.
Server Error in '/' Application. Parser Error Description: An error occurred during the parsing
My Error is as follows: Server Error in '/' Application. The view 'Login' or
@Html.Partial(~/Shared/SuccessErrorStatus) Server Error in '/' Application. The partial view '~/Shared/SuccessErrorStatus' was not found or
Server Error in '/WebSite10' Application. Invalid postback or callback argument. Event validation is enabled
I am getting 500 Internal Server Error , when loading my new asp.net application.
Currently I am getting error pages like this: Server Error in '/' Application. The
I get this error when calling my service: Server Error in '/' Application. --------------------------------------------------------------------------------
My web application presents a very strange error: Server Error in '/' Application. --------------------------------------------------------------------------------

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.