0

I have a bunch of users in my database. Each user has a profile image and the profile image is saved in App_Data folder. The location of the image is saved in the database along with other details of the user.

Example: C:\Users\Libin\Documents\Visual Studio 2015\Projects\SocialClubServer\SocialClub.WebAPI\App_Data\BodyPart_15a49f62-c900-4cbe-866a-a20e080101bb

I need to return the image url with other user details of all the users in my web api to use it in a client app (angular).

This is the method that returns the user info.

public IEnumerable<InfluencerDetail> GetBrands()
    {

        var allUsers = db.Users.Where(i => i.InfluencerUser != null).ToList();
        var users = allUsers.Select(u => new InfluencerDetail
        {
            FullName = u.InfluencerUser.FullName,
            ProfileImage = System.Web.Hosting.HostingEnvironment.MapPath(u.InfluencerUser.ProfileImage),
            ContentType = u.InfluencerUser.ContentType,
            BrandRating = u.InfluencerUser.BrandRating
        }).ToList();


        return users;
    }

The exception that I get when i use the above code is

 {"The relative virtual path 'C:/Users/Libin/Documents/Visual Studio 2015/Projects/SocialClubServer/SocialClub.WebAPI/App_Data/BodyPart_a1672749-73f3‌​-4e28-8614-db744740c728' is not allowed here."}
Anik Saha
  • 4,313
  • 2
  • 26
  • 41

0 Answers0