Bailey
Bailey
CC#
Created by Bailey on 4/22/2024 in #help
Multipart dataresponse compatible with swagger.
Hello, I'm searching for a way to define a multipart dataresponse, The following controller code accepts multipart formdata. In the code the fromForm icm with the model that it can receive multipart data. However, I'm searching how to define this part: [ProducesResponseType(typeof(testResponseModel), StatusCodes.Status200OK)] So My response can also send multipart data, and swagger will accept it. To be honest, I do not think it is a standard and is not supported by the defaults I can define in the testResponseModel to add IFormFile, but swagger does not see it as a multipartform while using FromForm (see request, it is multipart). Does anyOne know a sollution to respond as a multipart form data where there the metadata and file are multipart [HttpPost(Name = "SaveFile")] [ProducesResponseType(typeof(testResponseModel), StatusCodes.Status200OK)] public async Task<testResponseModel> StoreAsynchronous([FromForm] SaveFileModel request) { try { return null; } catch (Exception ex) { throw; } }
1 replies
CC#
Created by Bailey on 4/2/2024 in #help
✅ Theoretical question. MediatR and DTO and onion structure
Hello, THe following is just theoretical and I do not need any code In the programming world, transferring the received object from the api to other parts of the programm for processing is seen as bad practise. Keeping this in mind, then we should map the received data (could use automapper). However if I use the onion structure in combination with Mediatr, there is a mapping done automaticly. The reason why I think this is because MediatR (if I'm correct) uses reflection and generic types. This means that there already is a mapping (indirect). Now I think about using this structure without the mappings. ps. If I would use n-tier structure the mapping would go to the same properties in the object only from the contract to the dto. My question what are you're thoughts on this.
16 replies
CC#
Created by Bailey on 2/23/2024 in #help
✅ Entityframework for framework 4.8 instead of .net / core
Hello, I'm trying to use EF with framework 4.8. There is a version 6.4.4. When using this, I cant find a lot of options which are available in .net 6 version of EF. I'm searching for an equivalent of these options. Possible they do not exist. In this case I'm talking about the following: override to attach to a config: protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.ApplyConfiguration<ProductModel>(new ProductConfiguration()); // etc The configuration option: public class ProductConfiguration : IEntityTypeConfiguration<ProductModel> { public void Configure(EntityTypeBuilder<ProductModel> builder) { builder.ToTable("Products"); builder.HasKey(p => p.ProductId); builder.Property(p => p.ProductId) .HasColumnName("ProductId") .HasColumnType("uniqueidentifier") .IsRequired(); // etc
22 replies
CC#
Created by Bailey on 2/6/2024 in #help
✅ Running in the microsoft cloud
Hello, I have to create a service which can run on the cloud (specs are not everything). So I thought, cot net 8 is compatible and using mediatr pattern for aa service is also OK. However there are possible things I didnt think of like (I do not know the real name) serive on demand which starts a program only when there is a request. Has someone any advice ? Like some short manual or something
43 replies
CC#
Created by Bailey on 11/27/2023 in #help
using serilog (c#) in a vb.net
Hello, I have an old application which is written in vb.net. I'm searching for a sollution to use serilog. On internet I found 1 entry which says I have to add serilog to the global.asax of vb.net. In the global asax we need to add serilogger confioguration. My problem is that I cant use Log.Information in the program itself. Does anyone know a sollution. Im not a vb programmer
27 replies
CC#
Created by Bailey on 8/22/2023 in #help
❔ c# .net6 cryptograpy example
Hello. I'm searching for an example for encryption. I already looked at: https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.aes?view=net-6.0 I copied the example and I can overwrite the aeskey. However I can only use exactly 32 characters more or less are not allowed. ofcourse I kan add or remove characters to get to exactly 32. But I search for a good example where you can add any password /. key Hope some can help
7 replies
CC#
Created by Bailey on 8/16/2023 in #help
❔ nuget doesnt work anymore. I
Hi, I checked the settings and it seems good. https://api.nuget.org/v3/index.json I get the following error: The underlying connection was closed: An unexpected error occurred on a send. Unable to write data to the transport connection: but the strange thing is the url: [nuget.org] Failed to retrieve metadata from source 'https://azuresearch-ussc.nuget.org last part of the error: An error occurred while sending the request. The underlying connection was closed: An unexpected error occurred on a send. Unable to read data from the transport connection: going with IE to the json no problem does anyone know a sollution ?
22 replies
CC#
Created by Bailey on 7/24/2023 in #help
❔ Searching for good multiTask Example in List<task>
Hello, I'm seeking a good example of a multitask async I hope to clearify my question with the code. I'm trying to start multiple tasks which are defined in a list. Every time I try, I get stuck. I also want to be able to limit the amount of tasks. I hope someone has a simple example. Best Regards Code: namespace ConsoleApp1 { internal class Program { static void Main(string[] args) { // create objects to start a scoped task List<DiffentClass> diffentClasses = new List<DiffentClass>(); for (int i = 0; i < 10; i++) diffentClasses.Add(new DiffentClass()); foreach (var diffentClass in diffentClasses) { // begin task }
// Wait to finisch and merge ... } } } the task should be directed to: namespace OtherProjectApp { public class DiffentClass { public async Task<string> PlaceHolder(string LotsOfDate, int taskNumber) { for (int i = 0; i < 10000; i++) { Thread.Sleep(1000); await Console.Out.WriteLineAsync($"placeholder {taskNumber.ToString()}" ); } return "ready"; } } }
11 replies
CC#
Created by Bailey on 7/7/2023 in #help
❔ openid connect oauth2
Hello, Does anyone have a good example of oauth2 implementation with openId. Where the oauth token has to be validated against an endpoint Like (found this somewhere): .AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, options => { options.Authority = "https://aUTHORITY"; options.ClientId = "platformnet6"; options.ClientSecret = "123456789"; // need 1 without client secret options.ResponseType = "code"; options.CallbackPath = "/signin-oidc"; options.SaveTokens = true; options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = false, SignatureValidator = delegate(string token, TokenValidationParameters validationParameters) { var jwt = new JwtSecurityToken(token); return jwt; }, }; });
5 replies