user1972450
user1972450

Reputation:

asp .net mvc web api authentication filters session

public class BodyPhoto
{
    [Key]
    public int PhotoID { get; set; }

    public int UserID { get; set; }
    public virtual User User { get; set; }
    public DateTime Date { get; set; }
    public string PhotoSource { get; set; }

    public string MuscleGroup { get; set; }
}

I want to have a web api for this. User login to the website, and has unique UserID. User does a post with BodyPhoto. How can i make sure i save BodyPhoto with correct UserID.

I am confused how to implement this with asp.net web api. Maybe with sessions and authentication filters.

Upvotes: 0

Views: 926

Answers (1)

Van
Van

Reputation: 1387

similar to MVC, you can use the AuthorizeFilterAttribute to authenticate and authorise your api requests.

http://www.asp.net/web-api/overview/security/authentication-and-authorization-in-aspnet-web-api

Extend that attribute if you wish to implement your own membership/role provider.

Upvotes: 1

Related Questions