Home > Software design >  Querystring in the URL without?
Querystring in the URL without?

Time:07-23

I am working with asp.net core razor pages. I remember a years ago working with MVC, I was able to redirect to a page with querystring without the question mark, but a slash instead.

http://www.exampletest.com/contact/[email protected]

Now in with razor pages, the URL is back to looking like...

http://www.exampletext.com/[email protected]

Is there a way to once again get the querystring with a slash instead of question mark, like before?

My code is as follows:

            <a asp-page="Index" asp-route-id="[email protected]">
                @Html.DisplayFor(m => stock.Symbol) 
            </a>

The Index.cshtml page is in the "contact" directory.

CodePudding user response:

The "querystring without the question mark" is known as route data, with each item occupying a segment of the URL. Route data parameters are defined in a route template, which you pass to the @page directive in the Razor file itself.

Change the @page directive in the Index.cshtml to the following and it should all magically work:

@page "{id}"
  • Related