P R Deltoid
P R Deltoid
CC#
Created by P R Deltoid on 4/29/2024 in #help
Setting up MAUI example project, project won't build
I am trying to set up my environment to play around with the MAUI samples here: https://github.com/dotnet/maui-samples I cloned the repo, navigated to maui-samples\8.0\Apps\WeatherTwentyOne\src\ and opened the .sln file there in Rider. I ran dotnet workload restore per Rider's prompting and it installed the required workloads. But when I run the project using the UWP configuration, I receive this error:
Microsoft.PackageDependencyResolution.targets(266, 5): [NETSDK1005] Assets file 'C:\Users\Taylor\Code\c-sharp\maui-samples\8.0\Apps\WeatherTwentyOne\src\WeatherTwentyOne\obj\project.assets.json' doesn't have a target for 'net8.0-windows10.0.19041.0'. Ensure that restore has run and that you have included 'net8.0-windows10.0.19041.0' in the TargetFrameworks for your project.
Microsoft.PackageDependencyResolution.targets(266, 5): [NETSDK1005] Assets file 'C:\Users\Taylor\Code\c-sharp\maui-samples\8.0\Apps\WeatherTwentyOne\src\WeatherTwentyOne\obj\project.assets.json' doesn't have a target for 'net8.0-windows10.0.19041.0'. Ensure that restore has run and that you have included 'net8.0-windows10.0.19041.0' in the TargetFrameworks for your project.
I also have the same error for the net8.0-android , net8.0-ios , and net8.0-maccatalyst targets. What am I doing wrong here?
2 replies
CC#
Created by P R Deltoid on 10/2/2023 in #help
ASP.NET API Controller not returning values shown in debugger
No description
3 replies
CC#
Created by P R Deltoid on 9/26/2023 in #help
Setting BaseURI for named HttpClient in DI not including trailing string
I am trying to use a named HttpClient setup in a Blazor WASM application. In my DI setup, I create it using the following:
builder.Services.AddScoped<AuthorizationMessageHandler>();
builder.Services.AddHttpClient("apiClient",
client => client.BaseAddress = new Uri("http://localhost:5199/api/v1/"))
.AddHttpMessageHandler(sp =>
sp.GetRequiredService<AuthorizationMessageHandler>().ConfigureHandler(new[] { "http://localhost:5199" }));

builder.Services.AddScoped<HttpClient>(sp => sp.GetRequiredService<IHttpClientFactory>()
.CreateClient("apiClient"));
builder.Services.AddScoped<AuthorizationMessageHandler>();
builder.Services.AddHttpClient("apiClient",
client => client.BaseAddress = new Uri("http://localhost:5199/api/v1/"))
.AddHttpMessageHandler(sp =>
sp.GetRequiredService<AuthorizationMessageHandler>().ConfigureHandler(new[] { "http://localhost:5199" }));

builder.Services.AddScoped<HttpClient>(sp => sp.GetRequiredService<IHttpClientFactory>()
.CreateClient("apiClient"));
However, when the HttpClient is injected into a Razor page and used to query my API using this code:
ChorePageResultDTO res = await httpClient.GetFromJsonAsync<ChorePageResultDTO>($"/Chores?page={state.Page+1}?pageSize={state.PageSize}") ?? new ChorePageResultDTO();
ChorePageResultDTO res = await httpClient.GetFromJsonAsync<ChorePageResultDTO>($"/Chores?page={state.Page+1}?pageSize={state.PageSize}") ?? new ChorePageResultDTO();
it makes a request like so:
info: System.Net.Http.HttpClient.apiClient.LogicalHandler[100]
Start processing HTTP request GET http://localhost:5199/Chores?page=1?pageSize=10
info: System.Net.Http.HttpClient.apiClient.ClientHandler[100]
Sending HTTP request GET http://localhost:5199/Chores?page=1?pageSize=10
info: System.Net.Http.HttpClient.apiClient.LogicalHandler[100]
Start processing HTTP request GET http://localhost:5199/Chores?page=1?pageSize=10
info: System.Net.Http.HttpClient.apiClient.ClientHandler[100]
Sending HTTP request GET http://localhost:5199/Chores?page=1?pageSize=10
It seems to be dropping the "/api/v1/" portion of the base URI for the request but using the base host/port that I provided (the port running this web application is 5000, which I assume would be the HttpClient default if I hadn't provided a new BaseAddress in my configuration.) Why is it dropping this portion and how can I get it to stop?
3 replies
CC#
Created by P R Deltoid on 5/19/2023 in #help
✅ Compiling ASP.NET 7 app using Github Actions
I am trying to compile my ASP.NET 7 application solution using Github actions but am getting the following error: error CS0234: The type or namespace name 'Authentication' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?) when building a project that requires this package. My github action looks like this:
name: .NET

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
name: .NET

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
I figured the GitHub Action's dotnet setup would have included these files. I know this isn't exactly a C# question but I figured people here might have experience with this particular problem. I'm a little confused on how my local build could find these files but the Github Action build cannot Probably related, but I am also receiving warnings: Could not locate the assembly "Microsoft.AspNetCore.Http.Features" Could not locate the assembly "Microsoft.AspNetCore.Authentication.Cookies"
108 replies