How can i restraint certain route not to be used.
In my startup.cs I have two mapendpoint
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "botConfiguration",
pattern: "bot/{botID}/{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
In my controller
public IActionResult Setting(int botID)
{
//botConfigRepository.GetAll();
return View();
}
The idea I would like to say if botID is not defined in my route, then you can't call this action, or it would redirect to the main page of some sort.
Now I know I coudl do an
if (botID == 0 ){
return RedirectToAction("Index");
}
Of some sort but to write this for every action sound kind of painfull.