---
title: "Problem in View Code in MVC4"  
description: "Problem in View Code in MVC4"  
author: "Gaurpriya Bishnoi"  
published: 2015-07-16  
updated: 2015-07-16  
canonical: https://www.mindstick.com/forum/23345/problem-in-view-code-in-mvc4  
category: "asp.net mvc"  
tags: ["linq", "mvc4"]  
reading_time: 1 minute  

---

# Problem in View Code in MVC4

hi i am [face](https://yourviews.mindstick.com/story/2258/ipl-2023-see-the-stunning-images-of-virat-kohli-and-gautam-gambhir-ugly-face-off) [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) in [view](https://yourviews.mindstick.com/view/84701/layoffs-in-google-india-2023-view) [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii)**\****[Controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc)**

```
public ActionResult Testing()        {            //var res = (from empname in db.UserMasters            //              select empname.EmployeeId).Distinct().ToList();          //var res = db.UserMasters.Select(x=> new  UserMaster{EmployeeId=x.EmployeeId}).Distinct().ToList();            var res = db.UserMasters.Select(x=>x.EmployeeId).Distinct();            return View(res);        }
```

\
**View Code Here**

```
@model IEnumerable<SampleApp.Models.UserMaster>@{    ViewBag.Title = "Testing";}@foreach (var item in Model){    <li><a href="#">@item.EmployeeId</a></li>}
```

\
**screenshot**\
![Problem in View Code in MVC4](https://www.mindstick.com/mindstickforums/c74294d7-4562-43c4-ba28-0ee1b2ce945d/images/bca016dc-13f9-4a5e-a0f9-fe46a593756a.png)\

## Replies

### Reply by Anonymous User

Hi Gauripriya\
Change code in razor view file..@model IEnumerable<SampleApp.Models.UserMaster>Replace with**@model List<SampleApp.Models.UserMaster>**


---

Original Source: https://www.mindstick.com/forum/23345/problem-in-view-code-in-mvc4

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
