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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:25:56+00:00 2026-06-05T22:25:56+00:00

I lack understanding of some basic MVC concepts, despite all my searching. I created

  • 0

I lack understanding of some basic MVC concepts, despite all my searching.

I created an MVC project in Visual Studio, which contains the partial view _LogOnPartial.shtml. I just want to access information within the view pertaining to the user, to put in a user dropdown menu. When I try to put this at the top of the partial view cshtml page I get the above error:

@model MyProject_MVC.Models.UserRepository

When I try this I also get an error:

@Html.Partial("_LogOnPartial", MyProject_MVC.Models.UserRepository)

‘MyProject_MVC.Models.UserRepository’ is a ‘type’, which is not valid in the given context

  • 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-05T22:25:57+00:00Added an answer on June 5, 2026 at 10:25 pm

    You have to provide an instance of MyProject_MVC.Models.UserRepository to the partial view. _LogOnPartial is strongly-typed to that type. It lets you access its public members at compile time and decide how you can display it in your view.

    If you want to use your own type in that view, first you have to change the type that is strongly-typed to it.

    @model MyProject_MVC.Models.UserRepository
    

    Then you have to create an instance of that type in your action method and pass it to the view as the model or a property of the model.

    public ActionResult LogOn()
    {
        return View(new UserRepository());
    }
    

    Now you can access this instance as Model object in your view.

    @Html.Partial("_LogOnPartial", Model);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to do some really basic math here, but my lack of understanding of
I am considering to move to mongoDB but I lack some certain basic understanding
Having some trouble (lack of understanding) with how to calculate percentages. I need to
I have been converting some code from C++ to C#. My lack of understanding
One thing I lack understanding on is how can code compiled for an Intel
This question probably is based on my lack of understanding of the role of
I'm having a tricky debugging issue, perhaps due to my lack of understanding about
Background I admit, this question stems from an ultimate lack of deep understanding of
This might be my lack of understanding of the call stack when using Core
So I'm writing some rspec tests and I'm embarrassed at my lack of Ruby

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.