acookook
acookook
CC#
Created by acookook on 2/28/2024 in #help
Running gRPC service inside a docker container on a kubernetes cluster
No description
2 replies
CC#
Created by acookook on 12/14/2023 in #help
Class library is not found while building the ASP.NET Core 7 Web API with Github Actions
I wrote this dotnet.yml to build my application and push the docker image to docker hub, placed in the root of my project under the folder .github/workflows/. In the solution (root/SolutionFolder/) I have class library RSO.Core Project and an ASP .NET Core (7.0) Web API project (both in standalone folders) which reference the RSO.Core project as "..\RSO.Core\RSO.Core.csproj" with following Dockerfile which is located in the the same folder as the Web API project and successfully builds locally. How to exactly refence these projects to get a successful docker build and push to the dockerhub repository? Is anything needed to remove from some cache? I was also considering to publish the RSO.Core project as a nuget package. In that case, what else could I implement to make my development faster as this would be tiresome. Getting those steps done would be some appreciated. https://stackoverflow.com/questions/77613904/class-library-is-not-found-while-building-the-asp-net-core-7-web-api-with-github
1 replies
CC#
Created by acookook on 12/3/2023 in #help
JWT implementation with .net 7.0 with Carter
I am trying to get some basic authorization to work also using the Carter nuget package. I simply cannot get the jwt authorization working. I'd also like to read data from the jwt, to use the data in my minimal API endpoints. All the relevant files I posted on gist, any suggestions or improvements are welcome. https://gist.github.com/shanji97/19022c72218e07e692667c1042223903
1 replies
CC#
Created by acookook on 6/5/2023 in #help
✅ Attachment upload to Jira through a custom application using AJAX and ASP .NET Core 6 - Rest Sharp
14 replies
CC#
Created by acookook on 3/28/2023 in #help
❔ Problem with including C DLL in a C# console app project.
So I have this C DLL imported into my console app (.NET 5). I simply cannot get to call it correctly, since everytime I get, something along the lines, that something with the entrypoint is broken, like: System.EntryPointNotFoundException: 'Unable to find an entry point named 'getCalculatedFitting' in DLL 'BPCalculationDLL.dll'.' The code with which I am defining this is [DllImport("BPCalculationDLL.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "getCalculatedFitting")] public static extern int getCalculatedFitting(float[] fittinglData, uint length, char ch); Honestly I tried a few things, but none of them seem to work in the current VS2022 editor. Does anyone have any idea how import this DLL and call it in another function?
86 replies
CC#
Created by acookook on 1/26/2023 in #help
Display the one layout based if the user is logged ( a dummy login system) in or the other if not. (
So I would like to display one layout with multiple pages (and remove Index.cshtml) and the other if the user is not logged in. I tried many ways, but I simply cannot figure out how to do that.Program.cs
builder.Services.AddRazorPages();
// Cookie settings.
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options => {options.LoginPath = "/Login"; options.AccessDeniedPath="/Login";});

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()){app.UseExceptionHandler("/Error");app.UseHsts();}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy(new CookiePolicyOptions() { });
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endPoints => { endPoints.MapRazorPages();endPoints.MapControllerRoute(
name: "default",
pattern: "{controller=Login}/{action=Index}/{id?}");
});
builder.Services.AddRazorPages();
// Cookie settings.
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options => {options.LoginPath = "/Login"; options.AccessDeniedPath="/Login";});

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()){app.UseExceptionHandler("/Error");app.UseHsts();}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy(new CookiePolicyOptions() { });
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endPoints => { endPoints.MapRazorPages();endPoints.MapControllerRoute(
name: "default",
pattern: "{controller=Login}/{action=Index}/{id?}");
});
The Login.cshtml on the Layout 2
@page
@model mOrders.Pages._LoginModel @{ Layout = "_LoginLayout";}<!--Login HTML-->
@page
@model mOrders.Pages._LoginModel @{ Layout = "_LoginLayout";}<!--Login HTML-->
The Viewstart.cshtml
@{
Layout = "_Layout";
}
@{
Layout = "_Layout";
}
The index.csthml on the Layout 1 (This should be removed)
@page "/"
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">Generic ASP text</div>
@page "/"
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">Generic ASP text</div>
Another cshtml in the Layout 1 (Requires Login)
@page "/MakeOrders" @model PartsModel @{ViewData["Title"] = "Make Orders";}
<!--Logged in user can see this-->
@page "/MakeOrders" @model PartsModel @{ViewData["Title"] = "Make Orders";}
<!--Logged in user can see this-->
The Login function in the in login controller is the following:
public IActionResult Login()
{
var claimsIdentity = new ClaimsIdentity(new List<Claim>{...}, CookieAuthenticationDefaults.AuthenticationScheme);
var authProperties = new AuthenticationProperties {};
Task.WaitAll(HttpContext.SignInAsync(
CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentiity,....)
return LocalRedirect("/MakeOrders");
}
public IActionResult Login()
{
var claimsIdentity = new ClaimsIdentity(new List<Claim>{...}, CookieAuthenticationDefaults.AuthenticationScheme);
var authProperties = new AuthenticationProperties {};
Task.WaitAll(HttpContext.SignInAsync(
CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(claimsIdentiity,....)
return LocalRedirect("/MakeOrders");
}
10 replies