How to prevent HttpGet method being called?

So i have a regular method and a HttpGet method: //Create a new note public ActionResult EditNote() { return View(); } //Edit a selected note [HttpGet] public ActionResult EditNote(int id) { var model = NotesProcessor.LoadNote(id); return View(model); } They both use the same views page, but only the HttpGet method will fill up the page… Read More How to prevent HttpGet method being called?

Adding a button for the end of the ul list

In my asp.net MVC application, I’m using signalR for push notifications. There I load the notifications to the ul list like this. <ul class="nav navbar-nav navbar-right"> <li role="presentation" class="dropdown open"> <a class="dropdown-toggle info-number" data-toggle="dropdown" aria-expanded="false" onclick="LoadData();"> <i class="fa fa-envelope-o"></i> <span class="badge bg-green" id="notiCount">0</span> </a> <ul id="menu1" class="dropdown-menu list-unstyled msg_list" role="menu"></ul> </li> </ul> So I check… Read More Adding a button for the end of the ul list

Js function passes null to the controller, in the old version

I need to wrote a code on an older version of the .net Framework, namely 4.5.2. I ran into a problem, the ajax code sends an empty request to the controller. Here is the form and I need to check user Full Name on unique: <div class="register-card"> <h1>Register the new user</h1> @using (Html.BeginForm("CreateUserAsync", "Home", FormMethod.Post))… Read More Js function passes null to the controller, in the old version

Unable to resolve service for type Microsoft.EntityFrameworkCore.DbContextOptions .net6

i’m Using .net 6 when i will create a Controller using the VS: Unable to resolve service type "Microsoft.Entity.FrameworkCore.DbContextOptions" 1[Biblioteca.Data.Contexto] while attempting to activate ‘Biblioteca.Data.Contexto’.’ That is my Model: using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace Biblioteca.Models { [Table("Livro")] public class Livro { [Display(Name="Id")] [Column ("Id")] [Key] public int Id { get; set; } [Display(Name = "Nome")]… Read More Unable to resolve service for type Microsoft.EntityFrameworkCore.DbContextOptions .net6

C# : How to Deserialize json data

How to deserialized this type of json file usig C# My Json [{"data":{"CRC":"a459","PC":"3000","TID":"e2806810200000040a0652c8","antenna":3,"channel":922.75,"eventNum":396,"format":"epc","idHex":"e28068100000003c0a0652c8","peakRssi":-36,"phase":0.0,"reads":36},"timestamp":"2022-09-19T09:03:26.445+0700","type":"SIMPLE"}] My Model public class TagRead{ public string TID { get; set; } } public class Hdr{ public List<TagRead> data { get; set; } } My Controller public ActionResult RefreshData() { string filepath = GetAndGenFilePath(); FileInfo fileInfo = new FileInfo(filepath); bool isFileLocked =… Read More C# : How to Deserialize json data

Using "asp-for" on a double or decimal property results in a type=text input

According to https://docs.microsoft.com/en-us/aspnet/core/mvc/views/working-with-forms?view=aspnetcore-6.0#the-input-tag-helper, asp-for should change the input type attribute according to the bound property. However, that’s not what I’m getting. I’ve created a new ASP.NET 6 (MVC) webapp and created a model: public class MyModel { public double MyProperty { get; set; } = 1.45d; } and Index.cshtml to @model MyModel; <div class="text-center"> <input… Read More Using "asp-for" on a double or decimal property results in a type=text input

How can my modelstate be invalid when there are no constraints on it?

My ViewModel looks like this: public class BookingViewModel { public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } public DateTime CheckInDate { get; set; } public DateTime CheckOutDate { get; set; } //Need this to display which room was chosen by the user… Read More How can my modelstate be invalid when there are no constraints on it?