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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:05:15+00:00 2026-06-15T01:05:15+00:00

I’m developing a MVC 4 Web Site. In my site I have a login

  • 0

I’m developing a MVC 4 Web Site.

In my site I have a login form in a partial view and I’m rendering it in _layout.cshtml, it uses LoginModel.

I also have a contact form, it uses ContactModel

When I get to contact form and submit it everything is fine. It went to server side. After it executes I’m returning a view and binding it to ContactModel

Which is simply :

[HttpPost]
public ActionResult Contact(Contact model)
{
    if (ModelState.IsValid)
    {
        //somecode here
    }

    return View(model);
}

It’s getting complicated and MVC tries to bind ContactModel to login page and gives the following error

The model item passed into the dictionary is of type
‘My_Project.Model.ContactModel’, but this dictionary requires a model
item of type ‘My_Project.Models.LoginModel’.

My contact form view :

    @model My_Project.Model.ContactModel
@{
    ViewBag.Title = "Contact";
}

        @using (Html.BeginForm("Contact", "Home", FormMethod.Post, new { id = "formContact" }))
        {
            @Html.ValidationSummary(true)
            @Html.TextBoxFor(model => model.Name, new {@class = "c2inp1", @placeholder = "Name"})
            @Html.ValidationMessageFor(model => model.Name)
            <br/>
            @Html.TextBoxFor(model => model.Surname, new {@class = "c2inp2", @placeholder = "Surname"})
            @Html.ValidationMessageFor(model => model.Surname)
            <br/>
            @Html.TextBoxFor(model => model.Email, new {@class = "c2inp2", @placeholder = "Email"})
            @Html.ValidationMessageFor(model => model.Email)
            <br/>
            @Html.TextAreaFor(model => model.Message, new { @class = "c2inp3", @placeholder = "Message" })
            @Html.ValidationMessageFor(model => model.Message)
            <br/>            
            <input type="image" src="@Url.Content("~/Images/c2img4.png")" alt="" class="c2submit"/>
        }
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

My login form in partial view

    @model My_Project.Model.LoginModel

@{
    ViewBag.Title = "Log in";
}
@if (WebSecurity.IsAuthenticated)
{
    <hgroup class="title">
    <h1>@ViewBag.Title.</h1>
</hgroup>

    <section id="loginForm">
<h2>Use a local account to log in.</h2>
@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl }))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Log in Form</legend>
        <ol>
            <li>
                @Html.LabelFor(m => m.UserName)
                @Html.TextBoxFor(m => m.UserName)
                @Html.ValidationMessageFor(m => m.UserName)
            </li>
            <li>
                @Html.LabelFor(m => m.Password)
                @Html.PasswordFor(m => m.Password)
                @Html.ValidationMessageFor(m => m.Password)
            </li>
            <li>
                @Html.CheckBoxFor(m => m.RememberMe)
                @Html.LabelFor(m => m.RememberMe, new { @class = "checkbox" })
            </li>
        </ol>
        <input type="submit" value="Log in" />
    </fieldset>

}
</section>


</section>
}

In my _layout.cshtml im rendering login form

@Html.Partial("_LoginPartial")

How can I solve this issue?

  • 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-15T01:05:16+00:00Added an answer on June 15, 2026 at 1:05 am

    You need to specify the model you want to pass to the login view in _layout.cshtml view…

    Example:

    @Html.Partial("_yourloginview", new LoginModel())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,

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.