最近的asp.net技术demo

1.多行的下拉菜单连接
http://www.uptop.cn/ordermrp/demo/DropDownList/demoDDL.aspx 


2.日期控件连接
http://www.uptop.cn/ordermrp/demo/Calendar/demoCalendar.aspx
3.可排序,列拖动,ctrl单选,shift复选,单元格拖动(在页脚拖动),存储过程分页,表头跟随滚动的DataGrid
http://www.uptop.cn/ordermrp/demo/storePage/DataGridCustomPaging.aspx
4.父子级关系,单元格拖动(在页头拖动),存储过程分页的DataGrid
http://www.uptop.cn/ordermrp/demo/fatherGrid/index.aspx
5.快速搜索,自动索检,从数据库中取数据
http://www.uptop.cn/ordermrp/demo/quickSearch/menu.aspx


6.N级树结构+导航菜单,从数据库中取树结构
http://www.uptop.cn/ordermrp/demo/treeView/menutree.aspx

代码在整理中,更多的asp.net技术demo请访问
http://www.uptop.cn/ordermrp/demo/index.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
下面是一个简单的ASP.NET Core JWT鉴权授权的demo,可以作为参考: Startup.cs文件: ```csharp using System.Text; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.IdentityModel.Tokens; namespace JwtDemo { public class Startup { public IConfiguration Configuration { get; } public Startup(IConfiguration configuration) { Configuration = configuration; } public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = Configuration["Jwt:Issuer"], ValidAudience = Configuration["Jwt:Audience"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:SecretKey"])) }; }); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); } } } ``` HomeController.cs文件: ```csharp using System; using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; using System.Text; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.IdentityModel.Tokens; namespace JwtDemo.Controllers { public class HomeController : Controller { private readonly IConfiguration _configuration; public HomeController(IConfiguration configuration) { _configuration = configuration; } public IActionResult Index() { return View(); } [HttpPost] public IActionResult Login(string username, string password) { if (username == "admin" && password == "password") { var claims = new[] { new Claim(JwtRegisteredClaimNames.Sub, username), new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), new Claim(JwtRegisteredClaimNames.Iat, DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer64), new Claim(ClaimTypes.Role, "Admin") }; var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["Jwt:SecretKey"])); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); var token = new JwtSecurityToken( issuer: _configuration["Jwt:Issuer"], audience: _configuration["Jwt:Audience"], claims: claims, expires: DateTime.UtcNow.AddMinutes(30), signingCredentials: creds); var response = new { token = new JwtSecurityTokenHandler().WriteToken(token) }; return Ok(response); } return BadRequest(); } [Authorize(Roles = "Admin")] public IActionResult Secret() { return Ok("You have access to this action because you are an Admin!"); } } } ``` appsettings.json文件: ```json { "Jwt": { "Issuer": "https://localhost:44363", "Audience": "https://localhost:44363", "SecretKey": "your secret key" }, "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } } } ``` 在以上示例中,我们定义了一个Login方法用于生成JWT,并将其作为响应返回给客户端。我们还定义了一个Secret方法,并添加了Authorize特性,指定需要验证的角色为Admin。当客户端请求该方法时,ASP.NET Core会自动进行JWT验证,并根据角色信息进行授权。 示例中的SecretKey为示例密钥,实际应用中应使用更加安全的密钥。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值