I had a completely functioning program at version 2.2 when migrating to version 3.0 and replacing
public void ConfigureServices(IServiceCollection services)
{
...
services.AddMvc();
}
With services.AddControllers();
And replacing app.UseMvc();
With:
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
One of the controllers is broken. (Other controllers which also has Post Method and [FromBody] Works fine) The controller and the method broken is:
[Route("api/vm")]
public class MainController: Controller
{
[HttpPost]
[Route("Process")]
public IActionResult GetProcess([FromBody]ProcessModel[] process)
{
...
}
}
The Model:
public class ProcessModel
{
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("ExeName")]
public string ExeName { get; set; }
[JsonProperty("Path")]
public string Path { get; set; }
[JsonProperty("VersionPath")]
public string VersionPath { get; set; }
[JsonProperty("Id")]
public string Id { get; set; }
[JsonProperty("Status")]
public string Status { get; set; }
[JsonProperty("Ver")]
public string Ver { get; set; }
[JsonProperty("Args")]
public string[] Args { get; set; }
[JsonProperty("Instances")]
public List<ProcessDetails> Instances { get; set; }
[JsonProperty("Multiple")]
public string Multiple { get; set; }
}
The call I am making to /api/vm/Process
:
[
{
"Name": "Test",
"ExeName": "Test",
"Multiple": false,
"Path": "Test",
"VersionPath": "Test",
"Args": {
"IsFile": false
}
},
{
"Name": "Test",
"ExeName": "Test.exe",
"Multiple": false,
"Path": "Test",
"VersionPath": "Test",
"Args": {
"IsFile": false
}
}
]
The app worked at production just fine for a few months. All I did was upgrade to .netcore 3, Now when I debug and get to the method at the controller I get null in a process variable
Note: I used this thread when the app was broken at first place Using 'UseMvc' to configure MVC is not supported while using Endpoint Routing