I would like to give the access to users to access the API methods.
For Example : Please see the below action method which can be access by user "hrushi",
But in my scenario we want to put user list from database.
Is there any best way to do this ?
I hope question is clear now....
namespace myApp.Controllers
{
using myApp.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web.Http;
[Authorize(Users = "hrushi")]
public class ValidateController : ApiController
{
// GET: Validate
public object Get()
{
IEnumerable<string> headerValues = null;
string stuid = "";
string dob = "";
if (Request.Headers.TryGetValues("id", out headerValues) == true)
{
stuid = headerValues.FirstOrDefault();
}
ErrorReply objreply = new ErrorReply();
string baseUrl = Request.RequestUri.AbsolutePath;
DateTime STUDOB = Convert.ToDateTime(dob);
ValidateReply objValidReply = new ValidateReply();
if (CommonClass.STUDENT_EXISTS(stuid, STUDOB, ref objValidReply))
{
return objValidReply;
}
//return new string[] { "Hello REST API", "I am Authorized" };
}
}
}
What I have tried:
I am still waiting for the solution