Политика проверки подлинности ASP.NET

Do Нравится это

1st помещает весь ваш HTML-контент в массив, затем сделайте json_encode

$html_content="<p>hello this is sample text";
$json_array=array(

'content'=>50,
'html_content'=>$html_content
);
echo json_encode($json_array);
0
задан Rowan de Graaf 18 January 2019 в 10:17
поделиться

1 ответ

Вы можете попробовать пользовательскую авторизацию. См. Код ниже.

    [HttpPost]
    [CustomAuthorization(Foo.bar)]
    public HttpResponseMessage Post([FromBody] Foo foo)
    {
        if (foo.bar !== user.bar)
        {
            return;
        }
    }



    public class CustomAuthorizationAttribute : AuthorizeAttribute
{
    private readonly string allowedroles;
    public CustomAuthorizationAttribute(string roles)
    {
        this.allowedroles = roles;
    }
    protected override bool AuthorizeCore(HttpContextBase httpContext)
    {
        bool authorize = false;
        if (Me.bar != allowedroles)
        {
            authorize = true;
        }
        return authorize;
    }
    protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
    {
        filterContext.Result = new HttpUnauthorizedResult();
    }
}

Для получения более подробной информации вы можете пройти здесь :

0
ответ дан Piyali Das 18 January 2019 в 10:17
поделиться
Другие вопросы по тегам:

Похожие вопросы: