在ASP.NET Core中使用ASP.NET MVC CustomedAntribute

时间:2017-10-24 08:34:26

标签: c# asp.net-mvc asp.net-core-mvc

我有像这样的授权属性

FROM docker.aws.com:443/consumertech/ruby-nginx-lua-anti-scrape:latest

# copy app source
RUN mkdir -p /data/app/my-app
RUN mkdir -p /data/app/my-app/log
RUN mkdir -p /data/app/my-app/tmp

RUN touch /data/app/my-app/dockerized
WORKDIR /data/app/my-app

ARG rails_env

ENV BUILD_ENV $rails_env

COPY . /data/app/my-app
RUN gem install bundler

RUN bundle install --with="production development test"
RUN RAILS_ENV=development bundle exec rake assets:precompile


ENV RAILS_ENV $rails_env
ENV NEW_RELIC_KEY "41dfc2f90fb480fbd4d2df35b77fffde68e42c74"

# unicorn
EXPOSE 3000


# need to start both unicorn and nscd
RUN echo "#!/usr/bin/env sh \n \
service nscd start \n \
unicorn -c ./config/unicorn.rb -E ${RAILS_ENV} -p 3000 \n \
bundle exec passenger start -p 3000 \

" > go.sh


RUN chmod 0755 go.sh

CMD ["./go.sh"]

我想在使用ASP.NET Core MVC Controller / Action的新站点中使用此属性。 我试图在Startup.cs中配置像这样

public class CustomAuthAttribute : AuthorizeAttribute
{
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            base.OnAuthorization(filterContext);
            ...

        }
}

但它无法解析IFilterMetadata类型。有人可以帮帮我吗?谢谢

0 个答案:

没有答案