I do not know how to correctly explain the essence of this.

for example:

public class HomeController: Controller { public IActionResult Index() { return View(); } public IActionResult Test() { return View(); } } 

I can call http://blabla.gg/home/test

those. make calls using a predefined method. But I want to make arbitrary calls and process them.

In general, I want to call pages with parameters wrong:

http://blabla.gg/home/test?ff=10

that's how

http://blabla.gg/home/test/proizolnoe_name

    2 answers 2

    It turned out thanks to Igor.

    Add a route to the startup.cs file

     app.UseMvc(routes => { routes.MapRoute( name: "HomeRoute", template: "{controller=Home}/{action=test}/{arbitrary}/{id?}"); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); 

    in the controller add

     public IActionResult Test(string arbitrary, иные получаемые параметры) { return View(); } 
       System.Web.Routing.RouteCollection routes ... Route route = routes.MapRoute( "RouteHomeTest", // Route name "Home/Test/{arbitrary}", // URL structure new { controller = "Home", action = "Test", arbitrary = UrlParameter.Optional } ); routes.Insert(0, route); public IActionResult Test(string arbitrary) { return View(); } 
      • I have AspNetCore and there it all looks different. This is what routes.MapRoute routes are written (name: "default", template: "{controller = home} / {action = Index} / {id?}"); I now do not understand how to remake. In your version, it swears at UrlParameter - it doesn't know what it is - Zud71
      • Roughly figured out - Zud71