Last post Sep 01, 2019 06:07 PM by mgebhard
Sep 01, 2019 05:48 PM|TechView|LINK
Hello friends! I am learning ASP.NET Core Razor Pages, where am unable to figure out a thing (Silly one). So here it's: I've a
razor page where I show a list of data where I've to make the page routing or url as follows:
@foreach (var item in Model.Data)
<a href="./search_details/id/@item.Id">@item.Name @item.City @item.State</a>
So pretty simple, so in the Startup.cs, I tried to do the following to make it work. Unfortunately failed:
//This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
//Here is the configured routing that I tried
I would like to return the url as ./search_details/id/1002 and in the back-end, did this to get the query string value:
string id = this.RouteData.Values["id"].ToString();
This is pretty basic, but as I said failed (Failed means in the back-end, the query string doesn't hit while debugging). I've one more scenario and this thing is bothering me right now the most. My requirement is to hide the page name as
well. Something like this:
Is there appropriate way where I can accomplish that? I understand that's a bad practice for other purposes but for the time being, I would go with it.
N.B: I am not willing to do it in the client-end unless there is no alternate. If possible, better with something server-side using
Sep 01, 2019 06:07 PM|mgebhard|LINK
Your route parameter syntax is incorrect.
I recommend reading the following.