AbishkarKafle
AbishkarKafle
CC#
Created by AbishkarKafle on 11/14/2024 in #help
How Can I add Security Definition in Scalar
In Swagger We could Use

builder.Services.AddSwaggerGen(options =>
{
options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
{
In = ParameterLocation.Header,
Name = "Authorization",
Type = SecuritySchemeType.ApiKey
});
options.OperationFilter<SecurityRequirementsOperationFilter>();

builder.Services.AddSwaggerGen(options =>
{
options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
{
In = ParameterLocation.Header,
Name = "Authorization",
Type = SecuritySchemeType.ApiKey
});
options.OperationFilter<SecurityRequirementsOperationFilter>();
for adding tokens and such but How Can I add this functionality in Scalar In their website https://docs.scalar.com/swagger-editor#description/markdown-support they have
security:
- bearerAuth: []
- basicAuth: []
- apiKeyQuery: []
- apiKeyHeader: []
- apiKeyCookie: []
- oAuth2: []
security:
- bearerAuth: []
- basicAuth: []
- apiKeyQuery: []
- apiKeyHeader: []
- apiKeyCookie: []
- oAuth2: []
as the way to add the section to generate the tokens but how to do it in C# code
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
app.MapScalarApiReference(Options =>
{
Options
.WithTheme(ScalarTheme.BluePlanet)
.WithDefaultHttpClient(ScalarTarget.CSharp, ScalarClient.HttpClient);
});
}
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
app.MapScalarApiReference(Options =>
{
Options
.WithTheme(ScalarTheme.BluePlanet)
.WithDefaultHttpClient(ScalarTarget.CSharp, ScalarClient.HttpClient);
});
}
4 replies
CC#
Created by AbishkarKafle on 9/15/2024 in #help
Issue with not being able to register with google ReCaptcha v2
so I wanted to implement google recaptchav2 in my project but while doing so I got a problem where when I add click register button I am not able to register and it just reloads then when I want to the console to look for problem I saw Migrate entirely to Https to have cookies sent to same-site sub resource as issue what can I do to fix this if you request for code then I will be happy to provide it
10 replies
CC#
Created by AbishkarKafle on 3/29/2024 in #help
is this how you are suppose to use update using api in asp.net?
No description
24 replies
CC#
Created by AbishkarKafle on 1/9/2024 in #help
is there any way to make a placeholder text in WPF inside a textbox?
I haven't found any simple way to make it and I need help?
2 replies
CC#
Created by AbishkarKafle on 11/29/2023 in #help
✅ Can some one help me teach how to use ASP.NET Boilerplate with Angular
Hey everyone! I could use some help understanding how to integrate ASP.NET Boilerplate with Angular for a project. If anyone has resources, tutorials, or tips on this integration, I'd be grateful for your guidance
2 replies
CC#
Created by AbishkarKafle on 11/7/2023 in #help
❔ i want to add jwt in my api i am making should I put this in the same controller as my register
using HotelRservationAPI.DTO;
using HotelRservationAPI.Interface;
using HotelRservationAPI.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace HotelRservationAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class RegisterController : Controller
{
private readonly IRegisterRepository _registerRepository;

public RegisterController(IRegisterRepository registerRepository)
{
_registerRepository = registerRepository;
}

#region Post
[HttpPost]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult CreateRegister([FromBody] RegisterDto registerCreate)
{
if (registerCreate == null)
return BadRequest(ModelState);

var category = _registerRepository.GetRegisters()
.Where(c => c.Username.Trim().ToUpper() == registerCreate.Username.TrimEnd().ToUpper())
.FirstOrDefault();

if (category != null)
{
ModelState.AddModelError("", "Category already exists");
return StatusCode(422, ModelState);
}

if (!ModelState.IsValid)
return BadRequest(ModelState);

var categoryMap = new Register
{
Username = registerCreate.Username,
Password = registerCreate.Password,
Email = registerCreate.Email
};

if (!_registerRepository.CreateRegister(categoryMap))
{
ModelState.AddModelError("", "Something went wrong while saving");
return StatusCode(500, ModelState);
}

return Ok("Successfully created");

}
#endregion
}
}
using HotelRservationAPI.DTO;
using HotelRservationAPI.Interface;
using HotelRservationAPI.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace HotelRservationAPI.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class RegisterController : Controller
{
private readonly IRegisterRepository _registerRepository;

public RegisterController(IRegisterRepository registerRepository)
{
_registerRepository = registerRepository;
}

#region Post
[HttpPost]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
public IActionResult CreateRegister([FromBody] RegisterDto registerCreate)
{
if (registerCreate == null)
return BadRequest(ModelState);

var category = _registerRepository.GetRegisters()
.Where(c => c.Username.Trim().ToUpper() == registerCreate.Username.TrimEnd().ToUpper())
.FirstOrDefault();

if (category != null)
{
ModelState.AddModelError("", "Category already exists");
return StatusCode(422, ModelState);
}

if (!ModelState.IsValid)
return BadRequest(ModelState);

var categoryMap = new Register
{
Username = registerCreate.Username,
Password = registerCreate.Password,
Email = registerCreate.Email
};

if (!_registerRepository.CreateRegister(categoryMap))
{
ModelState.AddModelError("", "Something went wrong while saving");
return StatusCode(500, ModelState);
}

return Ok("Successfully created");

}
#endregion
}
}
by watching some tutorial i have made this much but i heard we need token auth to be safe so i was wondering is this where you put the jwt auth?
3 replies
CC#
Created by AbishkarKafle on 8/15/2023 in #help
❔ the data inside my datagrid is showing twice
8 replies