c# – .NET Core parâmetro JSON

Eu estou começando a aprender C#, usando .NET CORE, e estou tentando criar uma API que realiza buscas em um banco MongoDB.

Já procurei em alguns tópicos aqui, vi algumas coisas, mas nenhuma das soluções que encontrei funcionou.

Eu criei uma classe chamada SearchParameter para poder receber os parâmetros de busca, porém quando tento realizar a mesma no Insominia ele retorna o seguinte:

inserir a descrição da imagem aqui

Não consigo entender o que está havendo. Seguem as classes.

SearchParametrs:

public class SearchParameters
{
    // Propriedes

    (Required(ErrorMessage = "É necessário informar um parâmetro de busca."))
    (JsonProperty("ticketField"))
    public string ticketField { get; set; } // representa o campo do ticket que será utilizado para busca.

    (Required(ErrorMessage = "É necessário informar um parâmetro de comparação."))
    (JsonProperty("comparationParameter"))
    public string comparationParameter { get; set; } // representa o parâmetro de comparação, se o valor a ser buscado é IGUAL ou DIFERENTE do ticketField.

    (JsonProperty("initialDate"))
    public DateTime initialDate { get; set; } // representa a data incial de um período a ser pequisado.

    (JsonProperty("finalDate"))
    public DateTime finalDate { get; set; } // representa a data final de um período a ser pesquisado. 
}

Inicio do CONTROLLER, que define a rota:

(ApiController)
(Route("v1/archivedTickets"))
public class ArchivedTicketsController : ControllerBase
{...}

Método GET do CONTROLLER:

(HttpGet)
    (Route("getByChannelName/{searchParameters}"))
    public IActionResult getByChannelName(SearchParameters searchParameters)
    {
        try
        {
            return Ok(_repository.GetByChannelName(searchParameters));
        }
        catch (Exception exc)
        {
            return null;
        }
    }

Método que realiza a busca no REPOSITÓRIO:

public List<ArchivedTicketsModel> GetByChannelName(SearchParameters searchParameters)
    {
        return _collection.Find(archivedTicket => archivedTicket.ChannelName == searchParameters.ticketField && archivedTicket.DateCreation >= searchParameters.initialDate && archivedTicket.DateCreation <= searchParameters.finalDate).ToList();
        
    }

Eu coloquei um breakpoint na classe do CONTROLLER para debugar, mas o Insominia retorna essa mensagem sem nem ao menos entrar no método GET.

Estou testando em um localhost, que é a minha base_url. Já tem receber os parâmetros de forma separada, e deu certo, mas o objeto JSON não vai, e eu quero receber esse objeto como parâmetro.

Publishing your page on the net


Quote Originally Posted by cheap stock
View Post

I bought the domain name from name cheap and the hosting now with Gix Hosting
So are you saying I need to do this with who ever provided the domain name and not the hosting service?

Gix should have provided nameservers to use in a welcome email or within their services detail page, or perhaps in the control panel, etc. You then take that to namecheap and change the nameservers from what they are now to the ones Gix provides. This namecheap knowledgebase article explains how to change the nameservers.

Nameservers basically tell browsers, mail servers, etc where services for a domain are located and so they need to be set to the host or the records need to be updated to point to the host but changing the nameserver is usually easiest method.

.net – Encrypt RSA PRIVATE KEY as OpenSSL using C#

I want to encrypt the RSA PRIVATE KEY given by the piece of code:

var privateKey = cert.GetRSAPrivateKey().ExportRSAPrivateKey()

This is giving the RSA PRIVATE KEY after decrypting using openssl with command:

rsa -text -in private.key -passin pass:passphrase

Now I want a private key as in the command:

OpenSSL> pkcs12 -in src_test_resources_bokkzbv.p12 -nocerts -passin pass:yEzgzmKPkAgj6p17sHnM-des
MAC verified OK
Bag Attributes
    friendlyName: name
    localKeyID: <some random hex>
Key Attributes: <No Attributes>
Enter PEM pass phrase: passphrase
Verifying - Enter PEM pass phrase: passphrase

Is there a way to do this in C# (.Net Core 3.1).
Someone please help with this.

asp.net mvc – Validaciones de expresiones regulares en formularios asp net core

Tengo una pequeña consulta, estoy haciendo validaciones haciendo uso de expresiones regulares pero al momento de escribir en el formulario me salen unos pequeños errores por decirlo así, como por ejemplo si hago uso de esta linea, al momento de escribir me prohíbe todas las demás letras pero me permite ingresar solo la letra E ya sea en mayúscula o minúscula

(Required(AllowEmptyStrings = false, ErrorMessage = "El RUT es Obligatorio"))
(RegularExpression("(^(0-9)+$)", ErrorMessage = "Solo se Permiten Números"))
(StringLength(10, ErrorMessage = "El RUT solo permite 10 dígitos"))

También presentó otro problema con esta expresión regular que me permite el ingreso de los números cuando solo debería ser poder ingresar letras.

(Required(ErrorMessage = "El Apellido del Usuario es Obligatorio."))
(RegularExpression("^(a-zA-Z )*$", ErrorMessage = "Solo se Permiten Letras"))
(StringLength(100, ErrorMessage = "El Numero de Caracteres de {0} debe ser al menos {2}.", MinimumLength = 3))

De antemano agradezco su ayuda.

Dot Net Api

ASP. NET Web API is a framework for building HTTP services that can be accessed from any client including browsers and mobile devices. It is an ideal platform for building RESTful applications on the . NET Framework.

Where can I find an ASP.NET Web Application (.NET Framework) project template

The project that visual studio 2019 creates for an ASP.NET Web Application (.NET Framework) MVC5 comes with Bootstrap 3.x and many other outdated components.

If you update Bootstrap, the premade web pages no longer render properly.
Also, the folder structure is not the best.

Is there a project template out there that has all essential components updated, and a clean-up folder structure?

I tried using Rider but they do not have a built-in template.

I went t the .Net Foundation GitHub and did not find any:
https://github.com/dotnet?q=.NET+framework&type=&language=c%23&sort=

I also search GitHubub and did not see any:
https://github.com/search?q=ASP.NET+Web+Application+%28.NET+Framework%29+project+template

I am looking for a project template that has the basic structure to create a Clean Architecture. in .NET Framework and not .NET Core

Thank you

.net – Base64 decode no reduce el tamaño?

Necesito usar base64 encode para trasladar un fichero de texto de un disco duro a un servidor.
El proceso ya existe y es un .vbs que abre un fichero Ade texto de, por ejemplo 562Kb, le hace un encode base64 y el resultado lo envía a un webService.
En el webService, se coge lo enviado, se hace un decode base64 y guarda el resultado en un fichero B.
El caso es que los562Kb originales, se convierten en un fichero de 1.124Kb, justo el doble…

Se que el encode amplía el tamaño del fichero porque usa 4bytes para representar 3bytes, por lo que es 2 veces más grande que el fichero sin comprimir.

Pero pensé que luego el “decode” volvería a reducir y dejar el tamaño original…
Por qué no?

Gracias.

.net – How to create a message using c# webApi

I have 2 entities, one users and one messages. I want to create an method to be able to create a message but assign it to current user that creates it.

public class AppUser
    {
        public int Id { get; set; }
        public string UserName { get; set; }
        public byte() PasswordHash { get; set; }
        public byte() PasswordSalt { get; set; }
        public DateTime Created { get; set; } = DateTime.Now;
        public string Gender { get; set; }
        public ICollection<Message> Messages { get; set; }
    }

(Table("Messages"))
    public class Message
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public string MessageBody { get; set; }
        public DateTime CreateDate { get; set; } = DateTime.Now;
        public int AppUserId { get; set; }
    }

I need an httpPost for a user to create a message so when i output user details, it shows also messages created by him

windows 10 – Why am I getting the nonsensical “0x8024402C” error when trying to install the .NET Framework 3.5 OFFLINE installer?

I have a computer next to me. It’s not connected to any network. I have just spent the whole night fighting BIOS settings to be able to install Windows 10 on it.

I’m going to use it for one single task (digitizing VHS tapes), which means I have zero need for it to ever connect to anything.

When trying to install the Elgato Video Capture software, it complains about .NET Framework 3.5 not being installed. And they link to the Microsoft webpage where it’s available. Of course, that page defaults to the minimal “online” installer, which is just an EXE which downloads the actual data over the network. So, on the same page, I hunted down the fine-print “offline installer” link, which is of course much bigger, and transferred over it (via an USB stick) to the offline computer.

But I get the same damn generic “0x8024402C” error even with the offline/full installer! It acts as if it’s trying to “download” data, even though it’s all supposed to be in the 200+ MB EXE file. That’s the whole point of it being a “full”/offline installer.

Yes, I have restarted the machine, as it suggests itself. That did nothing whatsoever. Same error.

Online, there’s of course tons of articles about this, all telling you things related to “fixing your network connection”… But there is no network connection to fix since the machine is supposed to be offline. That’s why I got the offline installer.

What can I possibly do now?

How to set up Google tag Manager configuration in ASP NET Core razor pages

I am very new to ASP NET Core razor pages. I have a requirement to set up Google Tag Manager in ASP NET Core razor pages. Usually in the ASP.Net solution we use Google Analytic’s tag.js script in page load. In angular we usually set up in app.module.ts/ app.component.ts.

But, I am to set up GTM tracking code/ id in ASP NET Core razor pages.

After set up, I need to send triggering conditions to GTM (like on button click send a event trigger to GTM so that it will in turn call the Google Analytics set up tag). Is there any helper class or plugins which I can use for the same ? Or in which file like Startup.cs , I can use the GTM configuration set up ?

Thank you.