asp.net-core-2.0

How to get ASP.NET Identity authentication ticket expiry in Razor Page?

天涯浪子 提交于 2020-01-06 07:21:09
问题 I'm using identityserver4 with ASP.NET Identity, with a cookie configured with SlidingExpiration = true and ExpireTimeSpan = 20 minutes. I would like to provide the user with a warning when they are about to timeout so am trying to access the ".expiry" value in the cookie. So far I have been able to read an expiry time using the Razor code below. However this is failing to read the correct expiry time when the user refreshes their ticket. According to the Microsoft docs SlidingExpiration

No parameterless constructor defined for this object in asp.netcore migrations

北城以北 提交于 2020-01-06 06:19:06
问题 I am new to ASP.NET Core. learning new version of .NET Core 2.0 using VS Code. I got stuck while doing creating database using migration. First, it gives an exception of implementation of IDesignTimeDbContextFactory. After solving this, it still gives an exception of No parameterless constructor defined for this object Here's my code for DbContextClass: public VegaDbContext CreateDbContext(string[] args) { IConfigurationRoot configuration = new ConfigurationBuilder() .SetBasePath(Directory

Is the Configuration object in Asp.Net Core 2.0, injectable in a class library project

狂风中的少年 提交于 2020-01-06 06:10:21
问题 I have had no problem setting up classes in Class Libraries, setting them up in services in the Startup.cs to be injectable and having them work as expected. In a test app I am working in. I have a data class library project plus my MVC app project (Core 2.0.1 and EF 2.0.1 and MVC6) In Startup.cs // *If* you need access to generic IConfiguration this is **required** services.AddSingleton<IConfiguration>(Configuration); services.AddOptions(); // Add our class objects so they can be injected

Is the Configuration object in Asp.Net Core 2.0, injectable in a class library project

▼魔方 西西 提交于 2020-01-06 06:08:48
问题 I have had no problem setting up classes in Class Libraries, setting them up in services in the Startup.cs to be injectable and having them work as expected. In a test app I am working in. I have a data class library project plus my MVC app project (Core 2.0.1 and EF 2.0.1 and MVC6) In Startup.cs // *If* you need access to generic IConfiguration this is **required** services.AddSingleton<IConfiguration>(Configuration); services.AddOptions(); // Add our class objects so they can be injected

How do you get a reference to an ASP.NET Core SignalR hub context outside of a controller?

社会主义新天地 提交于 2020-01-06 06:03:45
问题 I have just started using SignalR for ASP.NET Core. I have used SignalR for ASP.NET for a couple of years. I am using: Microsoft.AspNetCore.All 2.0.7 Microsoft.AspNetCore.SignalR 1.0.0-preview2-final Microsoft.AspNetCore.SignalR.Client 1.0.0-preview2-final It appears that in the ASP.NET Core version of SignalR I can no longer use GlobalHost or IConnectionManager to get a reference to a hub context. I can use DI to get a reference to the hub context in a controller without any problems. public

How do you get a reference to an ASP.NET Core SignalR hub context outside of a controller?

被刻印的时光 ゝ 提交于 2020-01-06 06:02:57
问题 I have just started using SignalR for ASP.NET Core. I have used SignalR for ASP.NET for a couple of years. I am using: Microsoft.AspNetCore.All 2.0.7 Microsoft.AspNetCore.SignalR 1.0.0-preview2-final Microsoft.AspNetCore.SignalR.Client 1.0.0-preview2-final It appears that in the ASP.NET Core version of SignalR I can no longer use GlobalHost or IConnectionManager to get a reference to a hub context. I can use DI to get a reference to the hub context in a controller without any problems. public

c# HttpResponseMessage.Content does not return MemoryStream correctly to HttpClient but using byte[] for return works

孤人 提交于 2020-01-06 04:38:08
问题 I am trying to use HttpClient.PostAsync to submit data to a Controller and then return a Bitmap in Memorystream created by QRCoder to HttpClient via IActionResult . If the Controller returns byte[] , the response.Content.ReadAsStringAsync().Result gets the correct MemoryStream data. However, if the Controller returns IActionResult , neither response.Content.ReadAsStringAsync().Result , response.Content.ReadAsByteArrayAsync().Result , response.Content.ReadStreamAsync() provides the expected

How to inspect asp.net core methods?

狂风中的少年 提交于 2020-01-05 07:14:31
问题 I created a new ASP.NET Core MVC application with individual user accounts authentication. I would like to see how they implemented some methods. I suppose I can do it since ASP.NET Core is open source project, but I can't find these methods in github repository. https://github.com/aspnet/AspNetCore/ I am highly interested in this method. https://localhost:portnumber/Identity/Account/Login Q1: How to find this method in my project and is it possible to debug it? Q2: Why I dont see

How to inspect asp.net core methods?

别来无恙 提交于 2020-01-05 07:14:30
问题 I created a new ASP.NET Core MVC application with individual user accounts authentication. I would like to see how they implemented some methods. I suppose I can do it since ASP.NET Core is open source project, but I can't find these methods in github repository. https://github.com/aspnet/AspNetCore/ I am highly interested in this method. https://localhost:portnumber/Identity/Account/Login Q1: How to find this method in my project and is it possible to debug it? Q2: Why I dont see

How to pass a service from .net core di container to a new object created with automapper

佐手、 提交于 2020-01-05 04:16:30
问题 I'm facing a scenario where I need to inject a service from asp.net core DI container to the constructor of an object created using automapper. I don't know if this is the best practice but let me explain what I'm trying to accomplish. I've an asp.net core mvc controller that receives a model parameter, just a POCO, that model needs to be converted into a ViewModel class that contains some business logic, data access etc, in that class object I want to get some info from the injected service,