Click here to Skip to main content
15,893,668 members
Home / Discussions / ASP.NET
   

ASP.NET

 
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 
QuestionASP maker 2018 Pin
Member 1292025327-Oct-19 11:23
Member 1292025327-Oct-19 11:23 
AnswerRe: ASP maker 2018 Pin
Richard MacCutchan27-Oct-19 22:19
mveRichard MacCutchan27-Oct-19 22:19 
QuestionDraw Shape in Canvas Pin
John_Ryder26-Oct-19 1:58
John_Ryder26-Oct-19 1:58 
AnswerRe: Draw Shape in Canvas Pin
Afzaal Ahmad Zeeshan26-Oct-19 9:19
professionalAfzaal Ahmad Zeeshan26-Oct-19 9:19 
GeneralRe: Draw Shape in Canvas Pin
John_Ryder29-Oct-19 19:49
John_Ryder29-Oct-19 19:49 
AnswerRe: Draw Shape in Canvas Pin
jkirkerx28-Oct-19 12:53
professionaljkirkerx28-Oct-19 12:53 
QuestionHow do i make my detailsviewmodel work Pin
Stefaneus22-Oct-19 6:31
Stefaneus22-Oct-19 6:31 
AnswerRe: How do i make my detailsviewmodel work Pin
jkirkerx23-Oct-19 10:54
professionaljkirkerx23-Oct-19 10:54 
QuestionHow do i make a bootstrap carousel work with Asp.net core Razor Pin
Stefaneus21-Oct-19 14:49
Stefaneus21-Oct-19 14:49 
AnswerRe: How do i make a bootstrap carousel work with Asp.net core Razor Pin
Richard Deeming22-Oct-19 1:00
mveRichard Deeming22-Oct-19 1:00 
GeneralRe: How do i make a bootstrap carousel work with Asp.net core Razor Pin
Stefaneus22-Oct-19 5:02
Stefaneus22-Oct-19 5:02 
GeneralRe: How do i make a bootstrap carousel work with Asp.net core Razor Pin
Richard Deeming22-Oct-19 5:14
mveRichard Deeming22-Oct-19 5:14 
GeneralRe: How do i make a bootstrap carousel work with Asp.net core Razor Pin
Stefaneus22-Oct-19 7:04
Stefaneus22-Oct-19 7:04 
Answer[REPOST] How do i make a bootstrap carousel work with Asp.net core Razor Pin
Richard Deeming22-Oct-19 1:03
mveRichard Deeming22-Oct-19 1:03 
QuestionSystem.Data.SqlClient.SqlException: 'The parameterized query '(@Name varchar(7),@Alias varchar(4),@Under_Group varchar(8000),@' expects the parameter '@Under_Group', which was not supplied.' in winforms of database in .net Pin
Member 1462438515-Oct-19 21:29
Member 1462438515-Oct-19 21:29 
AnswerRe: System.Data.SqlClient.SqlException: 'The parameterized query '(@Name varchar(7),@Alias varchar(4),@Under_Group varchar(8000),@' expects the parameter '@Under_Group', which was not supplied.' in winforms of database in .net Pin
Richard MacCutchan15-Oct-19 22:06
mveRichard MacCutchan15-Oct-19 22:06 

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.