Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2017/2019 Razor page keyboard shortcut to view cshtml.cs file(code behind)

Using older asp pages you could view the code behind pressing the F7 key. This short cut does not work for VS17/19.

I have tried some of the suggestions "Visual Studio hotkey to switch between code behind and source file?" that did not work.

This is driving me crazy, and I know that it is a very simple fix, but i cannot find anything on the web about it.

So the goal

Press F7 or other function key to view the cshtml.cs file for the associated .cshtml file.

like image 234
TheBoz Avatar asked Oct 26 '25 16:10

TheBoz


1 Answers

There is a command available to do this for Razor Pages. It does not work for all .cshtml files (i.e. MVC views).

You can bind the command by configuring it in the Keyboard options. The command is called ProjectandSolutionContextMenus.Item.ToggleRazorView (not the most intuitive, I know). In the screenshot, I've already bound it to the F7 key: Showing command bound to F7

(note: this was previously reported through Developer Community (also sometimes called VS Feedback), which is a great way to make sure your feedback reaches the product team.)

like image 62
Jimmy Avatar answered Oct 28 '25 06:10

Jimmy