---
title: "Checking if file exists in asp.net mvc 4"  
description: "Checking if file exists in asp.net mvc 4"  
author: "Anonymous User"  
published: 2018-03-15  
updated: 2018-03-16  
canonical: https://www.mindstick.com/forum/34435/checking-if-file-exists-in-asp-dot-net-mvc-4  
category: ".net"  
tags: ["asp.net mvc", "mvc4"]  
reading_time: 1 minute  

---

# Checking if file exists in asp.net mvc 4

I want to [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) the existence of [image](https://www.mindstick.com/articles/23551/an-investigate-distinctive-seafood-restaurant-for-your-image-stamp-character) ... how to do this can [anyone help me](https://www.mindstick.com/forum/331/can-anyone-help-me-out-how-to-use-session-concept)..

```
 @if (Server.MapPath("~/Content/Images/UserImage/" +Model.ID + ".png"))
                {
                    <img src="~/Content/Images/UserImage/" + @Model.ID + ".png" alt="@Model.FirstName">
                }
```

Thanks..

## Replies

### Reply by Anonymous User

Try this am sure this will solve your problem

```
 @if (File.Exists(Server.MapPath("~/Content/Images/UserImage/" + Model..ID + ".png")))
                {
                    <img src="~/Content/Images/UserImage/" + @userDetails.ID + ".png" alt="@Model.FirstName">
                }
```


---

Original Source: https://www.mindstick.com/forum/34435/checking-if-file-exists-in-asp-dot-net-mvc-4

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
