Razor bad asp-route link generation2019 Community Moderator ElectionHow do I generate a random int number?How do I import a namespace in Razor View Page?Escape @ character in razor view engineUsing Razor within JavaScriptMVC 4 @Scripts “does not exist”Anchor tag helper to open view in new window-tabASP.NET Core Route Tag Helper use Route?asp-route does not generate expected urlASP .NET Core 2.1 Razor Pages anchor tag helper generates empty href for asp-routegetting error when trying to use custom route in anchor tag helper
Giving a career talk in my old university, how prominently should I tell students my salary?
(Codewars) Linked Lists-Sorted Insert
Do Paladin Auras of Differing Oaths Stack?
What should I do when a paper is published similar to my PhD thesis without citation?
Writing text next to a table
How can a demon take control of a human body during REM sleep?
Movie: boy escapes the real world and goes to a fantasy world with big furry trolls
Locked Away- What am I?
ESPP--any reason not to go all in?
Too soon for a plot twist?
Will expression retain the same definition if particle is changed?
Can I take the the bonus-action attack from Two-Weapon Fighting without taking the Attack action?
Are these two graphs isomorphic? Why/Why not?
Why aren't there more Gauls like Obelix?
Is it appropriate to ask a former professor to order a book for me through an inter-library loan?
The (Easy) Road to Code
Is there a logarithm base for which the logarithm becomes an identity function?
Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?
How do you make a gun that shoots melee weapons and/or swords?
Are all players supposed to be able to see each others' character sheets?
"If + would" conditional in present perfect tense
What is Tony Stark injecting into himself in Iron Man 3?
Why do we say 'Pairwise Disjoint', rather than 'Disjoint'?
PTIJ: Who was the sixth set of priestly clothes for?
Razor bad asp-route link generation
2019 Community Moderator ElectionHow do I generate a random int number?How do I import a namespace in Razor View Page?Escape @ character in razor view engineUsing Razor within JavaScriptMVC 4 @Scripts “does not exist”Anchor tag helper to open view in new window-tabASP.NET Core Route Tag Helper use Route?asp-route does not generate expected urlASP .NET Core 2.1 Razor Pages anchor tag helper generates empty href for asp-routegetting error when trying to use custom route in anchor tag helper
I try to make a pagination system. However I have problem with my code about razor asp-route.
Here is the controller:
[Route("blog")]
public class BlogController : BaseController
[Route("categorySlug")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery] int page)
return View();
And here is the razor tag helper used to generate the url:
<a class="link" asp-action="Category" asp-controller="Blog"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
I expected the generated href to be:
/blog/some-slug?page=1
But I have the following url instead:
/Blog/Category?categorySlug=some-slug&page=1
Is there a way to generate the wanted url with asp-route
?
c# asp.net-mvc razor asp.net-core
add a comment |
I try to make a pagination system. However I have problem with my code about razor asp-route.
Here is the controller:
[Route("blog")]
public class BlogController : BaseController
[Route("categorySlug")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery] int page)
return View();
And here is the razor tag helper used to generate the url:
<a class="link" asp-action="Category" asp-controller="Blog"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
I expected the generated href to be:
/blog/some-slug?page=1
But I have the following url instead:
/Blog/Category?categorySlug=some-slug&page=1
Is there a way to generate the wanted url with asp-route
?
c# asp.net-mvc razor asp.net-core
Change to[HttpGet("categorySlug")]
– Nkosi
Mar 6 at 16:23
Same problem. When I remove theasp-route-page="1"
it generate the good url (/blog/some-slug
) but when addingasp-route-page="1"
everything breaks.
– frank_lbt
Mar 6 at 16:28
1
do you have any other methods on this controller? You may want to try[Route("*categorySlug")]
as a catch-all-route to avoid having the routing add the method to the url (it's doing it because your route has no unique identifier for it to know to use this method).
– Erik Philips
Mar 6 at 16:29
No, I removed all other methods to do the test @ErikPhilips
– frank_lbt
Mar 6 at 16:31
And the catch-all-route not works. I forgot to say that my Startup.cs file look like this:app.UseMvc(routes => routes.MapRoute( name: "default", template: "controller=Home/action=Index/id?" ); );
. If I remove this route, no url is generated at all.
– frank_lbt
Mar 6 at 16:44
add a comment |
I try to make a pagination system. However I have problem with my code about razor asp-route.
Here is the controller:
[Route("blog")]
public class BlogController : BaseController
[Route("categorySlug")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery] int page)
return View();
And here is the razor tag helper used to generate the url:
<a class="link" asp-action="Category" asp-controller="Blog"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
I expected the generated href to be:
/blog/some-slug?page=1
But I have the following url instead:
/Blog/Category?categorySlug=some-slug&page=1
Is there a way to generate the wanted url with asp-route
?
c# asp.net-mvc razor asp.net-core
I try to make a pagination system. However I have problem with my code about razor asp-route.
Here is the controller:
[Route("blog")]
public class BlogController : BaseController
[Route("categorySlug")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery] int page)
return View();
And here is the razor tag helper used to generate the url:
<a class="link" asp-action="Category" asp-controller="Blog"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
I expected the generated href to be:
/blog/some-slug?page=1
But I have the following url instead:
/Blog/Category?categorySlug=some-slug&page=1
Is there a way to generate the wanted url with asp-route
?
c# asp.net-mvc razor asp.net-core
c# asp.net-mvc razor asp.net-core
edited Mar 6 at 16:24
frank_lbt
asked Mar 6 at 16:21
frank_lbtfrank_lbt
85112
85112
Change to[HttpGet("categorySlug")]
– Nkosi
Mar 6 at 16:23
Same problem. When I remove theasp-route-page="1"
it generate the good url (/blog/some-slug
) but when addingasp-route-page="1"
everything breaks.
– frank_lbt
Mar 6 at 16:28
1
do you have any other methods on this controller? You may want to try[Route("*categorySlug")]
as a catch-all-route to avoid having the routing add the method to the url (it's doing it because your route has no unique identifier for it to know to use this method).
– Erik Philips
Mar 6 at 16:29
No, I removed all other methods to do the test @ErikPhilips
– frank_lbt
Mar 6 at 16:31
And the catch-all-route not works. I forgot to say that my Startup.cs file look like this:app.UseMvc(routes => routes.MapRoute( name: "default", template: "controller=Home/action=Index/id?" ); );
. If I remove this route, no url is generated at all.
– frank_lbt
Mar 6 at 16:44
add a comment |
Change to[HttpGet("categorySlug")]
– Nkosi
Mar 6 at 16:23
Same problem. When I remove theasp-route-page="1"
it generate the good url (/blog/some-slug
) but when addingasp-route-page="1"
everything breaks.
– frank_lbt
Mar 6 at 16:28
1
do you have any other methods on this controller? You may want to try[Route("*categorySlug")]
as a catch-all-route to avoid having the routing add the method to the url (it's doing it because your route has no unique identifier for it to know to use this method).
– Erik Philips
Mar 6 at 16:29
No, I removed all other methods to do the test @ErikPhilips
– frank_lbt
Mar 6 at 16:31
And the catch-all-route not works. I forgot to say that my Startup.cs file look like this:app.UseMvc(routes => routes.MapRoute( name: "default", template: "controller=Home/action=Index/id?" ); );
. If I remove this route, no url is generated at all.
– frank_lbt
Mar 6 at 16:44
Change to
[HttpGet("categorySlug")]
– Nkosi
Mar 6 at 16:23
Change to
[HttpGet("categorySlug")]
– Nkosi
Mar 6 at 16:23
Same problem. When I remove the
asp-route-page="1"
it generate the good url (/blog/some-slug
) but when adding asp-route-page="1"
everything breaks.– frank_lbt
Mar 6 at 16:28
Same problem. When I remove the
asp-route-page="1"
it generate the good url (/blog/some-slug
) but when adding asp-route-page="1"
everything breaks.– frank_lbt
Mar 6 at 16:28
1
1
do you have any other methods on this controller? You may want to try
[Route("*categorySlug")]
as a catch-all-route to avoid having the routing add the method to the url (it's doing it because your route has no unique identifier for it to know to use this method).– Erik Philips
Mar 6 at 16:29
do you have any other methods on this controller? You may want to try
[Route("*categorySlug")]
as a catch-all-route to avoid having the routing add the method to the url (it's doing it because your route has no unique identifier for it to know to use this method).– Erik Philips
Mar 6 at 16:29
No, I removed all other methods to do the test @ErikPhilips
– frank_lbt
Mar 6 at 16:31
No, I removed all other methods to do the test @ErikPhilips
– frank_lbt
Mar 6 at 16:31
And the catch-all-route not works. I forgot to say that my Startup.cs file look like this:
app.UseMvc(routes => routes.MapRoute( name: "default", template: "controller=Home/action=Index/id?" ); );
. If I remove this route, no url is generated at all.– frank_lbt
Mar 6 at 16:44
And the catch-all-route not works. I forgot to say that my Startup.cs file look like this:
app.UseMvc(routes => routes.MapRoute( name: "default", template: "controller=Home/action=Index/id?" ); );
. If I remove this route, no url is generated at all.– frank_lbt
Mar 6 at 16:44
add a comment |
1 Answer
1
active
oldest
votes
Congifure route template using app.UseMvc
in Startup.cs
app.UseMvc(routes =>
routes.MapRoute(
name: "BlogRoute",
template: "blog/categorySlug");
//.. other routes
);
Update your link to use this route
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
A bit modified solution using action and controller names
Route configuration
routes.MapRoute(
name: "BlogRoute",
template: "blog/categorySlug",
defaults: new controller = "Blog", action = "Category" );
Link
<a class="link" asp-action="Category" asp-controller="Blog"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
Failed attempt
One may wonder what if we use attribute routing and force tag helper to use this route (by setting asp-route
)
[Route("blog")]
public class BlogController : Controller
{
[Route("categorySlug", Name = "BlogRoute")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery] int page)
//..
and link code
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
In this case page
value is completely ignored and resulting url is /blog/some-slug
Note
Various tests have shown that code in your question worked fine actually and you don't need to add a route in app.UseMvc
. For example the following link
<a class="link" asp-route="BlogRoute"
asp-route-value="val1"
asp-route-data="info"
asp-route-categorySlug="some-slug">1</a>
generates this url
/blog/some-slug?value=val1&data=info
But if you add asp-route-page="1"
it is just ignored and output is the same. It turns out that url genering excludes parameters with specific names such as page
, action
and controller
(area
works fine, possibly there are more keywords). So my solution is just a workaround specifically for page
parameter name. If you try to add action
or controller
parameter my solution will just generate stub value /path
.
So it means you can just use some other name than page
like this
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-pageNum="1">1</a>
And bind page
parameter to pageNum
name
[Route("categorySlug", Name = "BlogRoute")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery(Name = "pageNum")] int page)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55027731%2frazor-bad-asp-route-link-generation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Congifure route template using app.UseMvc
in Startup.cs
app.UseMvc(routes =>
routes.MapRoute(
name: "BlogRoute",
template: "blog/categorySlug");
//.. other routes
);
Update your link to use this route
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
A bit modified solution using action and controller names
Route configuration
routes.MapRoute(
name: "BlogRoute",
template: "blog/categorySlug",
defaults: new controller = "Blog", action = "Category" );
Link
<a class="link" asp-action="Category" asp-controller="Blog"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
Failed attempt
One may wonder what if we use attribute routing and force tag helper to use this route (by setting asp-route
)
[Route("blog")]
public class BlogController : Controller
{
[Route("categorySlug", Name = "BlogRoute")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery] int page)
//..
and link code
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
In this case page
value is completely ignored and resulting url is /blog/some-slug
Note
Various tests have shown that code in your question worked fine actually and you don't need to add a route in app.UseMvc
. For example the following link
<a class="link" asp-route="BlogRoute"
asp-route-value="val1"
asp-route-data="info"
asp-route-categorySlug="some-slug">1</a>
generates this url
/blog/some-slug?value=val1&data=info
But if you add asp-route-page="1"
it is just ignored and output is the same. It turns out that url genering excludes parameters with specific names such as page
, action
and controller
(area
works fine, possibly there are more keywords). So my solution is just a workaround specifically for page
parameter name. If you try to add action
or controller
parameter my solution will just generate stub value /path
.
So it means you can just use some other name than page
like this
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-pageNum="1">1</a>
And bind page
parameter to pageNum
name
[Route("categorySlug", Name = "BlogRoute")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery(Name = "pageNum")] int page)
add a comment |
Congifure route template using app.UseMvc
in Startup.cs
app.UseMvc(routes =>
routes.MapRoute(
name: "BlogRoute",
template: "blog/categorySlug");
//.. other routes
);
Update your link to use this route
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
A bit modified solution using action and controller names
Route configuration
routes.MapRoute(
name: "BlogRoute",
template: "blog/categorySlug",
defaults: new controller = "Blog", action = "Category" );
Link
<a class="link" asp-action="Category" asp-controller="Blog"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
Failed attempt
One may wonder what if we use attribute routing and force tag helper to use this route (by setting asp-route
)
[Route("blog")]
public class BlogController : Controller
{
[Route("categorySlug", Name = "BlogRoute")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery] int page)
//..
and link code
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
In this case page
value is completely ignored and resulting url is /blog/some-slug
Note
Various tests have shown that code in your question worked fine actually and you don't need to add a route in app.UseMvc
. For example the following link
<a class="link" asp-route="BlogRoute"
asp-route-value="val1"
asp-route-data="info"
asp-route-categorySlug="some-slug">1</a>
generates this url
/blog/some-slug?value=val1&data=info
But if you add asp-route-page="1"
it is just ignored and output is the same. It turns out that url genering excludes parameters with specific names such as page
, action
and controller
(area
works fine, possibly there are more keywords). So my solution is just a workaround specifically for page
parameter name. If you try to add action
or controller
parameter my solution will just generate stub value /path
.
So it means you can just use some other name than page
like this
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-pageNum="1">1</a>
And bind page
parameter to pageNum
name
[Route("categorySlug", Name = "BlogRoute")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery(Name = "pageNum")] int page)
add a comment |
Congifure route template using app.UseMvc
in Startup.cs
app.UseMvc(routes =>
routes.MapRoute(
name: "BlogRoute",
template: "blog/categorySlug");
//.. other routes
);
Update your link to use this route
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
A bit modified solution using action and controller names
Route configuration
routes.MapRoute(
name: "BlogRoute",
template: "blog/categorySlug",
defaults: new controller = "Blog", action = "Category" );
Link
<a class="link" asp-action="Category" asp-controller="Blog"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
Failed attempt
One may wonder what if we use attribute routing and force tag helper to use this route (by setting asp-route
)
[Route("blog")]
public class BlogController : Controller
{
[Route("categorySlug", Name = "BlogRoute")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery] int page)
//..
and link code
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
In this case page
value is completely ignored and resulting url is /blog/some-slug
Note
Various tests have shown that code in your question worked fine actually and you don't need to add a route in app.UseMvc
. For example the following link
<a class="link" asp-route="BlogRoute"
asp-route-value="val1"
asp-route-data="info"
asp-route-categorySlug="some-slug">1</a>
generates this url
/blog/some-slug?value=val1&data=info
But if you add asp-route-page="1"
it is just ignored and output is the same. It turns out that url genering excludes parameters with specific names such as page
, action
and controller
(area
works fine, possibly there are more keywords). So my solution is just a workaround specifically for page
parameter name. If you try to add action
or controller
parameter my solution will just generate stub value /path
.
So it means you can just use some other name than page
like this
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-pageNum="1">1</a>
And bind page
parameter to pageNum
name
[Route("categorySlug", Name = "BlogRoute")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery(Name = "pageNum")] int page)
Congifure route template using app.UseMvc
in Startup.cs
app.UseMvc(routes =>
routes.MapRoute(
name: "BlogRoute",
template: "blog/categorySlug");
//.. other routes
);
Update your link to use this route
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
A bit modified solution using action and controller names
Route configuration
routes.MapRoute(
name: "BlogRoute",
template: "blog/categorySlug",
defaults: new controller = "Blog", action = "Category" );
Link
<a class="link" asp-action="Category" asp-controller="Blog"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
Failed attempt
One may wonder what if we use attribute routing and force tag helper to use this route (by setting asp-route
)
[Route("blog")]
public class BlogController : Controller
{
[Route("categorySlug", Name = "BlogRoute")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery] int page)
//..
and link code
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-page="1">1</a>
In this case page
value is completely ignored and resulting url is /blog/some-slug
Note
Various tests have shown that code in your question worked fine actually and you don't need to add a route in app.UseMvc
. For example the following link
<a class="link" asp-route="BlogRoute"
asp-route-value="val1"
asp-route-data="info"
asp-route-categorySlug="some-slug">1</a>
generates this url
/blog/some-slug?value=val1&data=info
But if you add asp-route-page="1"
it is just ignored and output is the same. It turns out that url genering excludes parameters with specific names such as page
, action
and controller
(area
works fine, possibly there are more keywords). So my solution is just a workaround specifically for page
parameter name. If you try to add action
or controller
parameter my solution will just generate stub value /path
.
So it means you can just use some other name than page
like this
<a class="link" asp-route="BlogRoute"
asp-route-categorySlug="some-slug"
asp-route-pageNum="1">1</a>
And bind page
parameter to pageNum
name
[Route("categorySlug", Name = "BlogRoute")]
public async Task<IActionResult> Category([FromRoute] string categorySlug, [FromQuery(Name = "pageNum")] int page)
edited Mar 6 at 23:37
answered Mar 6 at 21:32
AlexanderAlexander
1,947316
1,947316
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55027731%2frazor-bad-asp-route-link-generation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Change to
[HttpGet("categorySlug")]
– Nkosi
Mar 6 at 16:23
Same problem. When I remove the
asp-route-page="1"
it generate the good url (/blog/some-slug
) but when addingasp-route-page="1"
everything breaks.– frank_lbt
Mar 6 at 16:28
1
do you have any other methods on this controller? You may want to try
[Route("*categorySlug")]
as a catch-all-route to avoid having the routing add the method to the url (it's doing it because your route has no unique identifier for it to know to use this method).– Erik Philips
Mar 6 at 16:29
No, I removed all other methods to do the test @ErikPhilips
– frank_lbt
Mar 6 at 16:31
And the catch-all-route not works. I forgot to say that my Startup.cs file look like this:
app.UseMvc(routes => routes.MapRoute( name: "default", template: "controller=Home/action=Index/id?" ); );
. If I remove this route, no url is generated at all.– frank_lbt
Mar 6 at 16:44