asp.net-core-2.0

where can be stored user info in .net core API project with angular

ぃ、小莉子 提交于 2019-12-20 05:49:21
问题 I have an angular project and i am using .net core 2.o Web API. I stored my user info in Jwt and i want log every database operation. I can access user info by sending jwt and taking from request.header in server side. But the problem is, where can be stored? In my old mvc projects, i could stored in session. But this project is API . And we work with JWT not session. How can i achieve that store UserInfo during the request start to end. And i want to access UserInfo from everywhere. This is

ASP.Net MVC Core 2 - Area Routing

二次信任 提交于 2019-12-20 05:28:06
问题 I'm trying to implement an Area for Administrators within my ASP.Net MVC Core 2 application. I have configured the route for the area as follows: // Default route app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); // Admin area route app.UseMvc(routes => { routes.MapRoute( name: "admin", template: "{area=Admin}/{controller=Home}/{action=Index}/{id?}"); }); This all works pretty well. This Admin area uses the same Layout as the

ASP.NET Core Route attributes available in entire controller class

北城余情 提交于 2019-12-20 03:45:08
问题 Is there a way to make attributes specified in the route available in the whole class? For instance, consider this Controller: [Route("api/store/{storeId}/[controller]")] public class BookController { [HttpGet("{id:int:min(1)}")] public async Task<IActionResult> GetBookById(int storeId, int id) { } } And this request: /api/store/4/book/1 Inside the GetBookById method, the storeId variable is correctly populated with 4 and the id variable with 1. However, instead of having to pass the storeId

asp.net core how can I stop http request from locking

寵の児 提交于 2019-12-20 03:19:32
问题 I am new to asp.net Core and so far I like it . I have a very simple action that just returns a string "Hello World" . My problem is that I think that http request are locking which is really slowing things down essentially just like this ASP.NET application to serve multiple requests from a single process . I am doing load testing my first request is 967 milliseconds however my 100th request takes 10927 milliseconds or 10 seconds which is incredibly long to return a simple string . This is

How to remove the role-related tables from ASP.NET Identity Core 2.0

旧巷老猫 提交于 2019-12-20 02:52:13
问题 With the advice read-elsewhere that Roles are a subset of Claims, I am looking at a clean way to ask the EF Core implementation in ASP.NET Identity not to create role-related tables in the ASP.NET Identity Core 2.0 template in VS 2017. Only claims are needed. The template uses public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } protected override void OnModelCreating

Reloading Options with reloadOnChange in ASP.NET Core

别来无恙 提交于 2019-12-20 02:27:40
问题 In my ASP.NET Core application I bind the appsettings.json to a strongly typed class AppSettings . public Startup(IHostingEnvironment environment) { var builder = new ConfigurationBuilder() .SetBasePath(environment.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{environment.EnvironmentName}.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables(); Configuration = builder.Build(); } public void ConfigureServices

How to access IConfigurationRoot in startup on .net core 2?

浪子不回头ぞ 提交于 2019-12-19 16:24:10
问题 I have written a custom ConfigurationProvider with the entity framework. Since I also want to make it updateable during runtime, I have created a IWritableableOption. I need to refresh the configuration after the update. This can be done via IConfigurationRoot.Reload. However, how can I get the IConfigurationRoot in .net core 2? What I have found, is that in previous versions the IConfigurationRoot was part of startup. In .net core 2 however, we have only the simpler type IConfiguration :

How to access IConfigurationRoot in startup on .net core 2?

独自空忆成欢 提交于 2019-12-19 16:23:27
问题 I have written a custom ConfigurationProvider with the entity framework. Since I also want to make it updateable during runtime, I have created a IWritableableOption. I need to refresh the configuration after the update. This can be done via IConfigurationRoot.Reload. However, how can I get the IConfigurationRoot in .net core 2? What I have found, is that in previous versions the IConfigurationRoot was part of startup. In .net core 2 however, we have only the simpler type IConfiguration :

MVC Routing template to represent infinite self-referential hierarchical category structure

大城市里の小女人 提交于 2019-12-19 10:36:11
问题 I have a product category table to represent a hierarchical category structure, a typical Parent-Child relationship table in the database. Fill it with Guitar Center's data as an example: If you render them to a page with <ul> and <li> : Texts in blue are the URLs I would like to generate. For any given category, the link consists of its slug and its parents' slugs. Note that the example I listed only has 2 parent-child levels. In theory, with the self-referential structure, any child could

How can pass data from AuthorizationHandler to Controller in Asp.net core

走远了吗. 提交于 2019-12-19 09:59:13
问题 I used a specific authorization policy for user log in, so created custom Authorization Handler. And I would like to display use a specific alert message if they failed the policy. I read the documentation and found that I could access AuthorizationFilterContext via casting AuthorizationHandlerContext. I tried to add message to HttpContext.Items property and access it in my controller, but it returns false when i check it with TryGetValue method. if (context.HasFailed && context.Resource is