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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:41:36+00:00 2026-05-29T08:41:36+00:00

I am learning MVC with Razor and have a simple question (I think). I

  • 0

I am learning MVC with Razor and have a simple question (I think). I am having trouble displaying the contents of a model in the view and am not sure why.

My view is a .cshtml page.
I am passing a model to it that is of type IEnumerable

I cannot get the ‘foreach’ statement to run in the below view. Interesting the <% characters are not coloured yellow in Visual Studio so I think I may have missed something. Any ideas? Here is my view code…

@model IEnumerable<HERE_MVC.Models.CheckIn>

@{
    ViewBag.Title = "Home";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Home - Main page</h2>

<% foreach (var checkIn in Model.CheckIn){ %>
   <li><%: checkIn.ID %></li>   
<% } %>

And my controller code looks like this…

    public ActionResult Home(string lat, string lon)
    {
        ViewBag.Message = "Welcome to HERE!";

        HEREModel m = new HEREModel();
        var v1 = m.GetEntitiesByLatLon(lat, lon);
        return View(v1);
    }

Thank you in advance, I’ve been trying to work this out for a while but with no luck.

  • 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-29T08:41:37+00:00Added an answer on May 29, 2026 at 8:41 am

    Brush up on your Razor syntax — Razor doesn’t use bee stings (<%). Try this:

    @model IEnumerable<HERE_MVC.Models.CheckIn>
    
    @{
        ViewBag.Title = "Home";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    
    <h2>Home - Main page</h2>
    
    @foreach (var checkIn in Model.CheckIn) {
       <li>@checkIn.ID</li>   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been learning .MVC recently and am having trouble understanding how to process
I'm learning MVC and am having trouble deciding when I should create a new
I am learning spring-mvc and I am doing a simple crud. I have a
(just learning MVC) I have created a model class: public class Employee { public
I am learning MVC 3 and I have not found people using some logic
I have a simple ASP.NET MVC 3 dummy app (just learning MVC coming from
I'm in the process of learning MVC 3, Razor, and EF Model First. I
I am learning spring mvc and hibernate. i have just finished simple site with
I am learning MVC and display a list of products in a view. @model
I am learning ASP.NET MVC now a days and I have found that most

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.