MVC architecture in RESTFUL API

What is model in MVC architecture, is it only request object or it can be any object carrying data? Then what will be the model in RESTFUL API.

sql server – Stored proceture execute time in core mvc vs in .net form

Since we have about 20 client data, the difference in execution time is visible. In the MVC application, objects are stored, while in the three-layer application or .Net form, each attribute data is stored in order. In the MVC application, when registering or saving a client in the database, it must go through several classes and folders, while in .Net form, when the client clicks the Register button, in that action button1_Click () there is a code for storing the procedure, ie saving a new client in the database . While in the MVC application, when a client presses the Register button, the first thing to do is to send the client object to Services, where each individual attribute is unpacked to check if they are entered correctly, if they are entered correctly the object is returned. it was our turn to check if the client object already exists in the database so that we do not have duplicates. Only when all this is checked, the data is ready for storage. When storing data, the Services method is called for registration, in which the Repository is called for saving data, and only in that method is the client object saved. In other words, we need more actions to add a new client to the database, while in .Net form everything is in one place, ie in the action onclick () the data is saved and should not be sent by other storage methods, so it takes less time for the stored procedure or data storage. In the MVC application, the object goes through various classes and methods, so then it is used and takes up more memory, then we have a slower stored data procedure, unlike in .Net form.

I just need to know if my theory is right, if its wrong can you tell me where im wrong.

mvcc – I am testing execute time for stored procedure in MVC and .net core Form

So, I am testing executed time for stored procedure in MVC and in .net core Forme. In MVC app is slower then in .net form. In MVC it takes about 450ms and in .Net Form it takes 14ms. And i dont know why is that diffrence, can anybody explain to me that. mvc – Ajax call is being accidently triggered

I’m creating a login page and at the bottom of the pop-up form, there is another button that takes you to the registration page. The issue appears to be that when navigating to the new page it all sits under the original sign-in form which uses an ajax call to check if the user exists so when they try to submit the registration form it then calls that ajax call from the sign-in form.

form

<div id="myForm">    
    <form onsubmit="return false;" id="loginForm">

        <label for="email"><b>Email</b></label>
        <input type="email" id="email" placeholder="Enter Email" name="email" required>

        <label for="psw"><b>Password</b></label>
        <input type="password" id="psw" placeholder="Enter Password" name="psw" required>
        <div id="message" class="alert-danger"></div>
        <br />
        <button type="submit" id="submit" class="btn">Login</button>
        <button type="button" class="btn cancel" onclick="closeForm();">Close</button>
    <div class="d-inline">            
        <button class="btn-info">@Html.ActionLink("User Registration", "SignUp", "SignUp_SignIn")</button>

Then the ajax call is

$(document).ready(function () {
        $("form").on('submit', function (event) {
            var data = {
                'email': $("#email").val(),
                'psw': $("#psw").val()
                type: "POST",
                url: 'SignUp_SignIn/CredentialCheck',
                data: data,
                success: function (result) {
                    if (result == true) {
                            $("#message").text("Login attempt was successful");
                    else {
                            $("#message").text("Email/Password didn't match any results");
                error: function () {
                    alert("It failed");
            return false;

ERROR autenticacion MVC LoginViewModel

tengo un proyecto con la autenticacion de MVC, Con cuentas de usuarios individuales, pero le agregue la autenticacion a travez de un paquete nuget, todo iva bien hasta que las vistas comenzaron a darme error: el error es el siguente en la vista Register y Login:

introducir la descripción de la imagen aquí

el error dice: el nombre del tipo o del espacio de nombres “RegisterViewModel” no se encotro (falta una directiva using o una referencia de ensamblado?)

favor ayudenme tengo varios dias de retraso en el proyecto por ese error 🙁

c# – Strategy Design Pattern in ASP.Net Core MVC Project

I tried to make a calculator using the Strategy pattern in ASP.Net Core MVC (following an example from the Internet)

Please review my code and tell me what could be wrong and how to make it better?

My interface:

public  interface ICalculator
        double Calculate(double FirstNumber, double SecondNumber);

I also have 4 classes (Addition, Multiplication, Division, Subtraction)
I will attach only one of them because they are almost identical.

public class Addition : ICalculator
        public double Calculate(double FirstNumber, double SecondNumber)
            return FirstNumber + SecondNumber;

Also here is my Context class.

 public class Context
        private ICalculator calculator;

        public Context (ICalculator operation)
            calculator = operation;

        public double execute (double FirstNumber, double SecondNumber)
            return calculator.Calculate(FirstNumber, SecondNumber);

Now here are my MVC elements.
Here is my model and controller.

public class CalcModel  
        public double FirstNumber { get; set; }
        public double SecondNumber { set; get; }
        public double Result { get; set; }

        public CalculationMethod calculationMethod { get; set; }
        public enum CalculationMethod
            Addition = '+',
            Substraction = '-',
            Multiplication ='*',
            Division = '/'


 public IActionResult IndexCalculator()
            return View(new CalcModel());

        public async Task<IActionResult> IndexCalculator(CalcModel model)
            switch (model.calculationMethod)
                case CalculationMethod.Addition:
                    Context myAddition = new Context(new Addition());
                     model.Result = myAddition.execute(model.FirstNumber, model.SecondNumber);
                case CalculationMethod.Division:
                   Context myDivision = new Context(new Division());
                    model.Result = myDivision.execute(model.FirstNumber, model.SecondNumber);
                case CalculationMethod.Multiplication:
                   Context myMultiplication =  new Context(new Multiplication());
                    model.Result = myMultiplication.execute(model.FirstNumber, model.SecondNumber);
                case CalculationMethod.Substraction:
                    Context mySubstraction = new Context(new Substraction());
                    model.Result = mySubstraction.execute(model.FirstNumber, model.SecondNumber);
            return View(model);
        } mvc – Website builds but publish to Azure fails after deleting files

Using Visual Studio 2019 to build a .Net Core website and publish to Azure was working fine up until I just deleted a DataContext file and an Entity class through Visual Studio. I can build and bring the site up locally without any issue but when I try to publish the site to Azure I get an error that the two files I deleted could not be found. I’ve checked in my code along with the solution file. The message is correct, those files are no longer available but I’m not understanding why it’s looking for them since I deleted them through VS and the solution/project file should have been updated. I’ve done some searching but can’t find anything that specifically address this. I guess I could roll back to right before I deleted the files but then I’l have to update some code. Anyone know if I can look somewhere that is referencing these files for publishing so I can delete the reference? I’ve searched the whole solution for the name of the files hoping I could find a reference but it isn’t finding anything.

web applications – Where to sync Database and Search-Database in MVC pattern

In your situation I would primarily consider how to keep this search service as decoupled as possible from the existing implementation. Given you’re using django will strongly influence your choices. Asynchronous event or signal-based solutions can be very robust for your particular problem.

Triggering on the database itself could work (though I don’t know that mechanism for sqlite specifically). However these implementations of notifications and hooks tend to be flavor specific. If you find yourself wanting to move to something other than sqlite you’ll find yourself at best re-implementing or worse, possibly having a substandard or no option.

The model itself is not where you want to do the work for a search service, but in django where it is responsible for persistent data manipulation, makes it a good candidate to start a trigger. Producing some kind of event on change that something else can respond to asynchronously keeps things decoupled and you can move the heavy lifting how how to respond to that signal elsewhere.

This has been done for you already as django offers an existing post_save signal from models you can listen for. This already separates your data access and gives you a nice area to put your business logic (such as filtering types of events you care about responding to). This should also minimize the amount of new code you would need to use rather than inheritance and mixins as you proposed. If you’re eager to learn, studying this type of architecture is useful.

From there I would consider asynchronously signaling the search service depending your implementation. Something already in python, message queues, and other IPC are all on the table depending on how your search service is implemented. The contents of that signal can be a simple “reindex” or even the incremental change depending on your requirements and needs.

design – How best to structure this MVC or Razor Pages web application given a required tcp/ip server data source that acts like a web api?

I am rewriting an old 4.0 web forms website that exposes an application’s data and logic to the web. I am moving this to a .net core mvc or razor page project. The website has minimal formatting logic and some take-input-and-return-data logic. I am not using his logic because he essentially wrote a procedural, non-OOP version.

I am a little ways into a Razor Pages project right now but am finding myself writing awkward code. My issue is all this data comes from a server socket listener that uses TCP/IP protocol to return xml-like text data.

This is great except the person who wrote the listener (cannot change and have 0 control over it) made it act like a pseudo web api. It is listening on a specific port and ip address. However, It closes the connection after he finishes responding to every request and the only security is relying on the connection coming from specific hosts/servers. So creating an SPA (ideal) is out of the question because I can’t connect from the client.

Therefore, all data and model creation has to be done on the server. I could wrap an actual api around the tcp listener but that is for another day. Let’s assume this TCP conundrum will not change. How do I best go about this?

I currently am injecting an IDataSource class into the pagemodels. I am then defining “models” that essentially define what data the pagemodel needs those models to have in order to function. I then implement the IDataSource in a class that knows about the tcp connection, call the listener, parse the xml, and return the “model” class as if it was a real repository.

Is there a better way to do this? I am trying to maintain SOC but the data coming back and what is displayed is so interconnected I am almost wondering if I should try another way. I was considering possibly switching to MVC and just have the controller know about the tcp connection and having it call the server, parse the data, and then create a viewmodel and return a view. Or at least injecting those functionalities into the controller while still letting the controller know about the data source.

This would be quicker and make for less awkward proxy classes for the data. Instead, the controller is the application and only shapes the data for different views. Not traditional, but this situation is a bit different.

Any input welcome. web api – Decodificar JWT PAYLOAD en WEB API MVC C#

Estoy desarrollando una WEB API en MVC con C#, la idea del API es que una aplicación de terceros me proporcionara un JWT y según me comentan lo que procede es deserializarlo o decodificar el PAYLOAD para extraer cierta información para ser usada en los métodos del API y asi realizar las consultas requeridas.

introducir la descripción de la imagen aquí

La idea en si es que en mi Controlador extraiga la información del TOKEN para realizar las consultas, en si no tengo mucho conocimiento sobre el tema de web tokens.

using Microsoft.IdentityModel.Tokens;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;

namespace TokenBasedAuthentication.Controllers
    public class getCredentialInfoController : ApiController
        public IHttpActionResult getCredentialInfo(String Matricula)
            AlumnosEntities sd = new AlumnosEntities();
            var results = sd.getCredentialInfo(Matricula).ToList();
            return Ok(results);

Espero puedan ayudarme con esto.

NOTA: El JWT es generado con GOOGLE OAUTH2