forum

Home / DeveloperSection / Forums / How to check file exist or not in MVC razor view?

How to check file exist or not in MVC razor view?

Anonymous User 2284 26-Dec-2017

Hi Expert,

I want to check file existence in 'if' condition of my application razor view.

Here is my code,

<span class="qa-q-item-avatar">

                            <a href="@Url.Action("user", "account", new { user = @item.UserName.Replace(" ", "-"), @id = item.UserID })" class="qa-avatar-link">
  if(fileExist){//here we want to check file existence
  <img src="https://www.mindstick.com//Content/img/User Image/@(item.UserID).png" width="30" height="30" class="qa-avatar-image">
  }
  else
  {
  other wise show default image
  }
        </a>
</span>

Please give me the solution to accomplish my task.


Updated on 26-Dec-2017
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By