我的控制器装饰有:[BasicAuthentication] - 但是,放置断点并单步执行代码,[BasicAuthentication] 永远不会重定向到 Auth.cs(在 Filter 文件夹中):
过滤器\Auth.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.Security;
namespace ebapi.Filter
{
public class BasicAuthenticationAttribute : System.Web.Http.Filters.ActionFilterAttribute
{
public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
{
所以覆盖 OnActionExecuting 永远不会执行 - 但我看不到我错过了什么。我的控制器,用 [BasicAuthentication] 装饰如下所示,但不调用上面显示的我的 Auth.cs:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using ebapi.Filter;
using ebapi.Models;
namespace ebapi.Controllers
{
public class GetBookingsController : ApiController
{
private GetBookingsContext db = new GetBookingsContext();
private ApiMembersContext dba = new ApiMembersContext();
// GET api/GetBookings/5
[BasicAuthentication]
public IEnumerable<GetBooking> GetBooking(long id)
{
谢谢你的帮助,
标记