WeihanLi.AspNetMvc.AccessControlHelper 1.1.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package WeihanLi.AspNetMvc.AccessControlHelper --version 1.1.0
NuGet\Install-Package WeihanLi.AspNetMvc.AccessControlHelper -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WeihanLi.AspNetMvc.AccessControlHelper" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WeihanLi.AspNetMvc.AccessControlHelper --version 1.1.0
#r "nuget: WeihanLi.AspNetMvc.AccessControlHelper, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install WeihanLi.AspNetMvc.AccessControlHelper as a Cake Addin
#addin nuget:?package=WeihanLi.AspNetMvc.AccessControlHelper&version=1.1.0

// Install WeihanLi.AspNetMvc.AccessControlHelper as a Cake Tool
#tool nuget:?package=WeihanLi.AspNetMvc.AccessControlHelper&version=1.1.0

GetStarted

  1. Nuget Package https://www.nuget.org/packages/WeihanLi.AspNetMvc.AccessControlHelper/

    安装权限控制组件 WeihanLi.AspNetMvc.AccessControlHelper

    asp.net:

    Install-Package WeihanLi.AspNetMvc.AccessControlHelper
    

    asp.net core:

    dotnet add package WeihanLi.AspNetMvc.AccessControlHelper
    
  2. 实现自己的权限控制显示策略类

    • 实现页面元素显示策略接口 IControlAccessStrategy
    • 实现 Action 访问显示策略接口 IActionAccessStrategy

    示例代码:

    • ASP.NET Mvc

    https://github.com/WeihanLi/AccessControlHelper/blob/master/samples/PowerControlDemo/Helper/AccessStrategy.cs

    • ASP.NET Core

    https://github.com/WeihanLi/AccessControlHelper/blob/master/samples/AccessControlDemo/Startup.cs#L60

  3. 程序启动时注册自己的显示策略

    • asp.net mvc

    Global 文件中注册显示策略

    AccessControlHelperExtensions.RegisterAccessStragety(new AccessControlHelperOptions
        {
            ActionAccessStrategy = new ActionAccessStrategy(),
            ControlAccessStrategy = new ControlAccessStrategy()
        });
    
    • asp.net core

    Startup 文件中注册显示策略

    // Method1
    app.UseAccessControlHelper(options =>
        {
            options.ActionAccessStrategy = new ActionAccessStrategy(),
            options.ControlAccessStrategy = new ControlAccessStrategy()
        });
    
    // Method2
    app.UseAccessControlHelper(new AccessControlHelperOptions
        {
            ActionAccessStrategy = new ActionAccessStrategy(),
            ControlAccessStrategy = new ControlAccessStrategy()
        });
    
    
  4. 控制 Action 的方法权限

    通过 AccessControlNoAccessControl Filter 来控制 Action 的访问权限

  5. 控制页面元素的显示

    通过 HtmlHelper 扩展方法来实现权限控制

Contact

如果您在使用中遇到了问题,欢迎随时与我联系。

Contact me: weihanli@outlook.com

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.13.0 1,104 10/19/2020
1.12.0 1,189 1/27/2020
1.11.0 662 1/19/2020
1.10.0 797 12/8/2019
1.10.0-preview-20191204-022215 409 12/4/2019
1.9.2 759 10/20/2019
1.9.1 715 10/15/2019
1.9.0 789 9/24/2019
1.8.2 777 9/3/2019
1.8.0 1,130 6/21/2019
1.6.0 1,115 2/21/2019
1.5.0 899 11/20/2018
1.4.0 930 10/10/2018
1.3.1 1,157 12/9/2017
1.1.0 1,192 10/16/2017

handle permission check move from ActionFilter to IAuthorizationFilter