When working with ASP.NET Core MVC applications, one of the most common issues developers face is the 404 – Page Not Found error. The browser typically shows:
This localhost page can’t be found
No web page was found for the web address:
https://localhost:7104/JobRolesController/index
HTTP ERROR 404
This error appears when the URL does not match a valid route, or when the controller, view, or routing configuration is incorrect.
In this article, we will understand why this error occurs and how to fix it step by step.
1. Understanding Why the Error Occurs
If your controller name is:
public class JobRolesController : Controller
{
public IActionResult Index()
{
return View();
}
}
You must access it using:
https://localhost:7104/JobRoles/Index
But many beginners make this mistake:
https://localhost:7104/JobRolesController/Index
This will always produce HTTP ERROR 404.
ASP.NET Core automatically removes the word “Controller” in the route.
2. Correct URL Format in ASP.NET Core MVC
The correct format is:
/ControllerNameWithoutController/ActionName
So for:
JobRolesController.cs
Index() action
The correct URL becomes:
https://localhost:7104/JobRoles/Index
Or simply:
https://localhost:7104/JobRoles
(because MVC loads the Index() method by default)
3. Verify Default Routing in Program.cs
Your Program.cs file must have the following route configuration:
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
If this line is missing, routing will not work, resulting in a 404 error.
Ensure you have:
builder.Services.AddControllersWithViews();
app.MapControllers();
This enables the MVC engine.
4. Ensure the View Exists in the Correct Folder
For MVC to load the view, the file must exist here:
Views
└── JobRoles
└── Index.cshtml
If:
folder name is incorrect, or
view file name is wrong
→ The framework throws a 404 error.
Make sure the folder name matches the controller name without “Controller”.
5. Double-Check Launch URL and Port
Sometimes the issue is as simple as hitting the wrong port.
Check launchSettings.json:
"applicationUrl": "https://localhost:7104;http://localhost:5104"
If you use a different port in the browser, you will get 404.

Join the conversation! Your thoughts help the community grow.