如何使用基于表单的身份验证来保护我的web api? [英] How can I securise my web api using forms based authetication?

查看:58
本文介绍了如何使用基于表单的身份验证来保护我的web api?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个web api,我想使用基于表单的身份验证来限制对它的访问。我是asp.net mvc的新手。我想知道使用基于表单的身份验证来保护Web API的最佳方法是什么。我希望对一些代码示例提供一些帮助。

I have a web api that I want to restrict the access to it using the forms based authentication. I am newbie at asp.net mvc. I want to know what is the best way to secure the web api using the forms based authentication. I hope for a little help with some code examples.

推荐答案

亲爱的Naufal07,



顶部您输入的控制器方法:



Dear Naufal07,

On the top of your controller's method you just typed:

[Authorize(Roles = "Administrator")] or [Authorize]





如果该控制器是管理员使用的方法。











if that controller's method used by Administrator.

or


[Authorize]





就在你的控制器顶部之前



on the top of your controller just before

public class <controller name=""></controller>





您的所有控制器方法都变得安全。



谢谢,

Manoj Kalla



your all method of controller become secure.

Thank You,
Manoj Kalla


这篇关于如何使用基于表单的身份验证来保护我的web api?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆