Click here to Skip to main content
15,915,019 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionChange datatable from column to row and bind it to gridview Pin
Anand Solomon14-Nov-19 5:19
Anand Solomon14-Nov-19 5:19 
QuestionAccessing Master Page Methods in Content Page and Accessing this.Master page Control from Class Library Pin
Member 1115418813-Nov-19 18:34
Member 1115418813-Nov-19 18:34 
AnswerRe: Accessing Master Page Methods in Content Page and Accessing this.Master page Control from Class Library Pin
F-ES Sitecore13-Nov-19 23:23
professionalF-ES Sitecore13-Nov-19 23:23 
GeneralRe: Accessing Master Page Methods in Content Page and Accessing this.Master page Control from Class Library Pin
Member 1115418814-Nov-19 0:17
Member 1115418814-Nov-19 0:17 
GeneralRe: Accessing Master Page Methods in Content Page and Accessing this.Master page Control from Class Library Pin
Richard Deeming14-Nov-19 1:25
mveRichard Deeming14-Nov-19 1:25 
Question[Solved] Retrieve Session Array variable to Array variable in Class Library Project Pin
Member 1115418813-Nov-19 0:00
Member 1115418813-Nov-19 0:00 
AnswerRe: Retrieve Session Array variable to Array variable in Class Library Project Pin
Richard Deeming13-Nov-19 2:15
mveRichard Deeming13-Nov-19 2:15 
GeneralRe: Retrieve Session Array variable to Array variable in Class Library Project Pin
Member 1115418813-Nov-19 2:48
Member 1115418813-Nov-19 2:48 
GeneralRe: Retrieve Session Array variable to Array variable in Class Library Project Pin
Richard Deeming13-Nov-19 3:36
mveRichard Deeming13-Nov-19 3:36 
GeneralRe: Retrieve Session Array variable to Array variable in Class Library Project Pin
Member 1115418813-Nov-19 4:58
Member 1115418813-Nov-19 4:58 
Questionwhat is major difference between blazor server app and asp.net mvc razor app? Pin
Nitin S11-Nov-19 18:10
professionalNitin S11-Nov-19 18:10 
AnswerRe: what is major difference between blazor server app and asp.net mvc razor app? Pin
Mycroft Holmes11-Nov-19 20:20
professionalMycroft Holmes11-Nov-19 20:20 
GeneralRe: what is major difference between blazor server app and asp.net mvc razor app? Pin
Nitin S11-Nov-19 22:04
professionalNitin S11-Nov-19 22:04 
GeneralRe: what is major difference between blazor server app and asp.net mvc razor app? Pin
jkirkerx13-Nov-19 9:56
professionaljkirkerx13-Nov-19 9:56 
Questiongridview with dynamic dropdownlist control null exception Pin
Anand Solomon11-Nov-19 4:41
Anand Solomon11-Nov-19 4:41 
Questionvideo calling in asp.net Pin
Member 146439065-Nov-19 18:37
Member 146439065-Nov-19 18:37 
AnswerRe: video calling in asp.net Pin
F-ES Sitecore6-Nov-19 1:04
professionalF-ES Sitecore6-Nov-19 1:04 
AnswerRe: video calling in asp.net Pin
Blikkies6-Nov-19 1:28
professionalBlikkies6-Nov-19 1:28 
Questioni want show page numbers in bottom of the page like <1 2 3 4 5.......10 11 12> but it shows <1 2 3 4 5 6 to total> Pin
Member 134445211-Nov-19 20:17
Member 134445211-Nov-19 20:17 
AnswerRe: i want show page numbers in bottom of the page like <1 2 3 4 5.......10 11 12> but it shows <1 2 3 4 5 6 to total> Pin
Richard Deeming3-Nov-19 22:33
mveRichard Deeming3-Nov-19 22:33 
QuestionASP.Net Core Identity Pin
Mycroft Holmes28-Oct-19 13:11
professionalMycroft Holmes28-Oct-19 13:11 
AnswerRe: ASP.Net Core Identity Pin
jkirkerx30-Oct-19 13:10
professionaljkirkerx30-Oct-19 13:10 
GeneralRe: ASP.Net Core Identity Pin
Mycroft Holmes31-Oct-19 11:13
professionalMycroft Holmes31-Oct-19 11:13 
GeneralRe: ASP.Net Core Identity Pin
jkirkerx1-Nov-19 12:23
professionaljkirkerx1-Nov-19 12:23 
JWT just generates a unique token, that contains information about the user, and some other parameters such as length of authorized time, and expiration date. So with a token, you can store it in the browsers Local Storage using JavaScript and read it back it using JavaScript. With JavaScript you can get info out of the token, or check to see if the token is expired, and then refresh it or issue a new one.

In Angular, you pickup the token, and pass the token in the header sent to the .Net Core V2.2+ API.
headers: new HttpHeaders({
  "Content-Type": "application/json",
  "Accept": "application/json",
  "Authorization": "Bearer " + tokenGetter
})
And then the API will run a service or something called Authorize.
[HttpGet("GetAdminBrands/{page}/{show}"), Authorize]
public async Task<GetBrands> GetAdminBrands(int page, int show)
{
    var brand = await _brandsRepository.GetBrands(page, show);
    return brand;
}
You set this up in Startup
services.AddAuthorization(auth =>
{
    auth.AddPolicy("Bearer", new AuthorizationPolicyBuilder()
        .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme‌​)
        .RequireAuthenticatedUser().Build());
});

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
    var settings = Configuration.GetSection("Settings");
    var secretKey = settings.GetValue<string>("Auth0:Secret");
    var signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(secretKey));
    var authority = settings.GetValue<string>("Auth0:Authority");
    var audience = settings.GetValue<string>("Auth0:Audience");

    options.RequireHttpsMetadata = false;
    options.TokenValidationParameters = new TokenValidationParameters
    {
        ValidateIssuerSigningKey = true,
        ValidateIssuer = true,
        ValidateAudience = true,
        ValidateLifetime = true,
        ValidIssuer = authority,
        ValidAudience = audience,
        IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey))
    };
});

So above is what I'm using now, which is Angular wrapped in .Net Core V2.2+

The code I posted earlier was a work around or hack to avoid using Microsoft.Identity in it's full scale, since I just wanted a partial portion of it. What I mean by full scale was having to use such a large chunk of controllers, models and views in which no explanation was really provided in how it works and why. Microsoft.Identity was take it or leave it with nothing in between. That prompted me to do some reverse engineering of it to see how it worked, and hack something else together that was more light weight.

When I think about it now, JWT pretty much works the same way as my hack does. But there's a large JavaScript client side library to support it, and is not all server side.

I did post questions about my hack 3 years ago and nobody bashed it. But I did hear crickets about it as to nobody here posted a single comment about it.
If it ain't broke don't fix it
Discover my world at jkirkerx.com

QuestionImporting Rows Into a List Pin
ibrahimayhans28-Oct-19 0:37
ibrahimayhans28-Oct-19 0:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.