# ASP.NET Core Razor Page files in VS2022 not added correctly in .elements project file

**URL:** https://talk.remobjects.com/t/asp-net-core-razor-page-files-in-vs2022-not-added-correctly-in-elements-project-file/26828
**Category:** Mercury
**Tags:** visual-studio
**Created:** [June 18, 2022, 11:23am UTC](https://talk.remobjects.com/t/asp-net-core-razor-page-files-in-vs2022-not-added-correctly-in-elements-project-file/26828 "2022-06-18T11:23:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![avonelle](https://talk.remobjects.com/user_avatar/talk.remobjects.com/avonelle/32/13001_2.png) [@avonelle](https://talk.remobjects.com/u/avonelle)
#### Post date: [June 18, 2022, 11:23am UTC](https://talk.remobjects.com/t/asp-net-core-razor-page-files-in-vs2022-not-added-correctly-in-elements-project-file/26828/1 "2022-06-18T11:23:10Z")

</div>

Elements 11.0.0.2745  
Visual Studio 2022 (Version 17.1.1)

There is a problem with the way Razor Page files are added to [ASP.NET](http://ASP.NET) Core Mercury projects when using Visual Studio 2022. (I don’t know about VS2019.)

If I create a Mercury project using the [ASP.NET](http://ASP.NET) Core Empty Web Application project template in VS2022, and then use **Add New Item** to add a **[ASP.NET](http://ASP.NET) Core Page Model** file from the Elements =\> Mercury Items =\> [ASP.NET](http://ASP.NET) Core templates, the file itself is fine. BUT it adds the file to the \*.elements project file as a `<Content>` node instead of a `<Razor>` node. It also adds the `<DependentUpon>` node inside the node for the file which I don’t think is needed. Here’s a comparison of the \*.elements file between Water on the left and VS2022 on the right:

![image](https://talk.remobjects.com/uploads/default/original/3X/9/b/9b3ca0c83225d9bdcd2cd1520d5c0a9142a42fe0.png)

This matters because the `<Content>` reference means that any anchor tag helper for this page doesn’t end up with the right href, so the navigation doesn’t work properly.

I added this to the \_Layout.cshtml:  
` <a class="nav-link text-dark" asp-area="" asp-page="/About">About</a>`

As a `<Razor>` element, href is “/About”.

But as a `<Content>` element, href is empty.

Unloading the project and manually editing the project file solves the problem for me.

As an aside…I assume you can’t do anything about this, but it would be great if **Add** =\> **Razor Page…** menu from a right click on **Pages** in the Solution explorer would allow me to create this kind of file, rather than needing to use the **New Item…** option and finding the template. Right now, choosing that option gives me an error “There are no scaffolders supported for this item.”

Thanks,

–Avonelle

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [June 18, 2022, 11:54am UTC](https://talk.remobjects.com/t/asp-net-core-razor-page-files-in-vs2022-not-added-correctly-in-elements-project-file/26828/2 "2022-06-18T11:54:39Z")

</div>

Logged as [bugs://E25954](https://www.remobjects.com/portal/bugs/?id=E25954).

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [June 22, 2022, 1:34pm UTC](https://talk.remobjects.com/t/asp-net-core-razor-page-files-in-vs2022-not-added-correctly-in-elements-project-file/26828/3 "2022-06-22T13:34:10Z")

</div>

[bugs://E25954](https://www.remobjects.com/portal/bugs/?id=E25954) was closed as fixed.
