asp.net - Get the url without the name of the method that called it -
i try url of website plus current controller without method called it.
inside examplecontroller, examplemethod request.url.tostring()
=>http://localhost:51747/.../examplecontroller/examplemethod
i need
http://localhost:51747/.../examplecontroller
the solution use parse , remove after last slash, not sure if there method using server info.
your issue can solved using 1 of url.action html helper overloads. generate example url:
http://localhost:51747/.../examplecontroller
you need do:
@url.action("examplecontroller", "index", null, request.url.scheme)
assuming using default asp.net mvc routing config.
in more detail, if action provide helper 1 set default in routeconfig, not specified in resulting url.
routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } );
see action = "index" default? whatever have set there have use when generating url.
Comments
Post a Comment