Files saved in folder are always excluded in solution explorer in MVC 4

1.4k views Asked by At

I have switched to c# from php, so little bit confused.I have a problem while saving image to the folder in MVC4.

There is a scenario where I need to save the image to the image folder in MVC4.The image is getting saved to folder but it is excluded.Every time to use this image I need to include this file. Please provide me the solution.Have tried in google and other blogs but I could'nt find out the solution.

The scenario is the registration process where I need to save the user image and show it when it gets login.But due to the fact that the image is excluded,the link seems to be broken or no image can be seen untill the image gets included from the solution explorer.

3

There are 3 answers

0
RajeshKdev On BEST ANSWER

Files saved in folder are always excluded - is not a problem. Probably you are providing the wrong path or inaccessible path to the image src.

When ever you are uploading the Images / Files - always you no need to include the file into your solution. Its a wrong approach.

The Problem is locating the Image file from the Html. The Given Path is the Problem, not including / excluding.

Solution to check the Image Path:

  1. Load the web page in Chrome browser.
  2. Right Click on the Image.
  3. And Open the Image in New Tab.
  4. Check the URL of your Image. Which is loaded.

Check out this Article.

0
Rama Kathare On

Go to the Solution folder, edit .csproj file. change the xml to include images automatically before build.

<Target Name="BeforeBuild">
    <ItemGroup>

....

<Content Include="*.yourimageextension" />

.....

    </ItemGroup>
</Target>
0
Chandrabhan Pradhan On

Just use src = @Href(path of image)