Categories
Development MVC

TempData not kept between postback

I need some advice on how to proceed with the mvc app I’m building. On my page I type out who is logged in to the page. This I first did by creating a base class where I created a user class which contained the users name and a image representing the user. Then I […]

Categories
API Development HTTP MVC React

Getting “reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response” while mocking a third part API

My Spring boot API is consuming a third part API using WebClient DemoAPIController @RestController public class DemoAPIController { @Autowired DemoService demoService; @GetMapping(“/mytest”) public Mono<UserType> getUserType() { return demoService.getUserType(); } } DemoService.java @Component public class DemoService { @Value(“${base.url}”) private String baseUrl; public Mono<UserType> getUserType() { System.out.println(“baseUrl:” + baseUrl); WebClient webClient = WebClient.builder().baseUrl(baseUrl) .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) .defaultHeader(“apikey”, “test”).build(); […]

Categories
Development Docker MVC Python

Send post-request from dockerized jar to local python-service

I am running a dockerized jar and a local flask-service on my Mac. The jar represents a web-app for a musical catalogue and the flask-service transforms musical notes into a xml-based music-encoding format. The service is called when the user has clicked on the download button. Starting the application through PyCharm and IntelliJ works fine, […]

Categories
API ASP.NET Development MVC

Getting CORS error in Angular 8 while trying to post data to Asp.net core web api

I am making CRUD using Angular 8 and Asp.net core. Everything works fine until I submit data. It returns me following error. Access to XMLHttpRequest at ‘http://localhost:56975/api/PaymentDetail‘ from origin ‘http://localhost:4200‘ has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response. I already add Microsoft.AspNetCore.Cors package. This is […]

Categories
Development HTML MVC

Filling specific cells in html table with razor pages

After trying to fill a html table with data from a MVC model, we ran into a problem. This code below generates a table, which is supposed to represent a schedule. The first row displays the days of the week, and the first column displays the number representation of the school hours. <table class=”table2″> <tr> […]

Categories
ASP.NET Development MVC

How to write custom console command for ASP.NET MVC application? To execute like “dotnet run my-custom-command arg1 arg2”

I’m trying to find information over the internet, but everything around points just to dotnet cli utility. It seems nobody or almost nobody asked for feature to have ability to run console command from MVC app. My reasons to have it: I have MVC app and I want to create custom console commands to: – […]

Categories
API Development MVC

How to identity whether It is MVC application or Web API application. I have many projects under one solution

I have many projects under one solution and all project look similar whether it is mvc or web api. I am new to the project so how will I identify whether it is mvc or web api project. Thanks in advance!

Categories
Development HTML MVC

Filling specific cells in html table with razor pages

After trying to fill a html table with data from a MVC model, we ran into a problem. This code below generates a table, which is supposed to represent a schedule. The first row displays the days of the week, and the first column displays the number representation of the school hours. <table class=”table2″> <tr> […]

Categories
ASP.NET Development MVC

ASP.Net Core 2.2 – separate serializer settings for input and output

ASP.Net Core 2.2 allows to set serializer settings using MvcJsonOptions.SerializerSettings property. The problem is that it affects both input and output. Is there a way to have separate options for input (deserialization) and output (serialization)? In particular, I need to set a different behavior for NullValueHandling settings: ignore null errors for non-nullable fields when deserializing […]

Categories
Development MVC

Request method ‘POST’ not supported when use @RequestParam

I am using Spring MVC. And get this error: Request method ‘POST’ not supported Java @RequestMapping(value = “/jdbcInsertGuest”, method = RequestMethod.POST) public void jdbcInsertGuest(@RequestParam(value = “guestName”) String guestName, @RequestParam(value=”comment”) String comment) { Guest guest = new Guest(); guest.setGuestName(guestName); guest.setComment(comment); jdbcExample.insertGuest(guest); } JSP <form name=”jdbcInsertGuest” method=”POST”> <table> <tr> <td><b>Name: </b></td> <td><input type=’text’ name=’guestName’/></td> </tr> <tr> <td><b>Comment: […]