Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What's the difference between <a asp-page="linkhere"> and <a href="linkhere"> in ASP.NET Core?

This is a fundamental question:

What’s the real difference between <a asp-area="" asp-page="/linkhere">test</a> and classic <a href="/linkhere">test</a> in ASP.NET Core?

The end result appears to be the same always (it’s an href attribute always in the end)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Does it somehow protect against clickjacking or something similar behind the scenes??

In other words, does using asp-page bring any security advantages?

>Solution :

You can customise the routing for Razor Pages, so that your LinkHere Razor Page and the URL to the page may be different. In that case, the asp-page approach ensures that the URL will match the page, but the href approach would need to be updated accordingly.

For an example of how a Razor Page URL can be customised, see Configure a page route:

options.Conventions.AddPageRoute("/Contact", "TheContactPage/{text?}");

In this example, the page Contact has a URL of TheContactPage with an optional extra segment.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading