I created a controller, TakeController.cs.
Suddenly, it just stopped working.
I added the following to Startup.cs:
app.Use((context, next) => { var endpoint = context.GetEndpoint(); Debug.WriteLine($"Endpoint: {endpoint.DisplayName}"); //if (SomeCondition) //{ // // Do some work //} return next(); });
On the other controllers, I see the name of the controller in the output console.
However, if I try and reach my controller, it's never even called.
I've cleaned and rebuilt the project, to no avail.
My enpoints are default:
` app.UseEndpoints(endpoints => { endpoints.MapHub
`
I created a new controller, called GoController.cs. It is picked up by the endpoint router, and calls Index() in the controller.
I tried removing my controller, and re-adding it, but it still doesn't get picked up... if I name it TakeController.cs
I've tried rebooting, as well.
I cleaned remove my obj and bin folders, everything builds and runs fine. I've compared project files for public
Might anyone have any suggestions why this happening, and how I can fix it?
Here's the source of my TakeController.cs:
` using Microsoft.AspNetCore.Mvc; using okto.work.Web.Controllers;
namespace okto.work.Web.Public.Controllers { public class TakeController : workControllerBase { //public IActionResult Index() //{ // return View(); //} // // GET: /HelloWorld/
public ActionResult Index()
{
return View();
}
//
// GET: /HelloWorld/Welcome/
public string Welcome()
{
return "This is the Welcome action method...";
}
}
} `
1 Answer(s)
-
0
I found the problem, but can't explain what caused it. Documenting here in case someone else faces this same issue.
For some reason, the iisexpress config picked up my controller's path as a Virtual Directory.
I edited the applicantionhost.config file in <root>.vs<project>\config.
Removing the virtual directories resolved the issue.