Make Razor Partials Navigable in VS Code

vscode razor aspnet umbraco developer-tools

I spend a lot of time in .cshtml files. That usually means jumping between views, partials, layout files, blocks, macros, and whatever naming convention the project has accumulated over the years.

Most of that navigation works well enough in VS Code. But partial views have always had one small annoyance: the editor can show me the string "_Header" inside @Html.Partial("_Header"), but it does not know where that file actually lives.

So I built Go To Partial, a small VS Code extension that adds Go to Definition support for Razor partial view references.

The source is available on GitHub, and it is also published on Open VSX.

The problem

Razor partials are usually referenced by name:

@Html.Partial("_Hero")
@await Html.PartialAsync("_ArticleCard")
<partial name="_Footer" />

That is perfectly normal ASP.NET MVC and Razor Pages code, but it leaves a gap in the editor experience. When I want to inspect _ArticleCard, I either search for the file manually or use the file picker and hope the partial name is unique enough.

On smaller projects this is just a minor interruption. On Umbraco projects, especially older ones, partials can live in several places:

  • next to the current view
  • in Views/Shared/
  • in Views/Partials/
  • in Pages/Shared/
  • inside an Area

That means the string in the .cshtml file is not just text. It is a reference. I wanted VS Code to treat it like one.

What Go To Partial does

After installing the extension, you can press F12 or Ctrl+Click a supported partial reference and jump directly to the resolved .cshtml file.

It supports the common helper methods:

@Html.Partial("_Name")
@Html.PartialAsync("_Name")
@await Html.PartialAsync("_Name")
@Html.RenderPartial("_Name")
@Html.RenderPartialAsync("_Name")

It also supports the built-in partial tag helper:

<partial name="_Name" />

Both short names and rooted paths work:

@await Html.PartialAsync("_ArticleCard")
@await Html.PartialAsync("~/Views/Shared/_ArticleCard.cshtml")

For short names, the extension follows the expected ASP.NET lookup pattern. It checks the current folder first, then shared and partial folders, and it also handles Areas/{areaName}/Views/Shared/ when the current file is inside an Area.

Live diagnostics

Navigation is useful when the reference exists. Broken references are the other half of the problem.

Go To Partial also adds live diagnostics for unresolved partial references. If a partial cannot be found, VS Code shows a warning squiggle on the reference.

That helps catch the boring mistakes early:

  • a renamed partial
  • a missing underscore
  • a typo in a string literal
  • a deleted view that is still referenced somewhere
  • a partial moved from Views/Partials/ to Views/Shared/

It is intentionally simple. It does not try to compile Razor, understand every possible C# expression, or become a full language server. It looks for the common static patterns and makes those nicer to work with.

Custom tag helpers

Some projects wrap partial rendering in custom tag helpers. For example:

<ec-partial name="_Footer" />

You can tell the extension about those element names in your workspace settings:

{
  "goToPartial.additionalPartialTagNames": ["ec-partial"]
}

If your tag helper uses a custom attribute instead of name, you can configure that too:

<cached-partial view-name="_Navigation" />
{
  "goToPartial.additionalTagHelperAttributes": ["view-name"]
}

With that in place, view-name="_Navigation" becomes navigable in the same way as a regular partial reference.

Installing

You can install it from the VS Code Extensions panel by searching for Go To Partial.

Or install it directly from:

If you prefer installing from a .vsix file, grab the latest release from GitHub Releases, then run Extensions: Install from VSIX… from the Command Palette.

When it helps

This is one of those tools that does not change how you build a site. It just removes a small bit of repeated friction.

I find it most useful when working in:

  • Umbraco sites with many partial views
  • ASP.NET MVC projects with old view conventions
  • Razor Pages projects with shared page fragments
  • projects using custom tag helpers for rendering view fragments

It is also handy when reviewing code. If I see:

@await Html.PartialAsync("_ProductTeaser", product)

I can jump straight into the partial instead of searching for it, checking whether it lives under Views/Shared, Views/Partials, or somewhere nearby.

Small Tools, Less Friction

Go To Partial is deliberately small. It adds editor navigation and warnings for a set of Razor patterns that I hit often, and it stays out of the way when those patterns are not present.

If you work in .cshtml files and partial views are part of your daily route through a codebase, it should save a few tiny interruptions. Sometimes that is enough to make the editor feel a little more connected to the code you are actually reading.