C# Dev Kit - Razor Hot Reload is not refreshing the browser automatically
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
## Is this a Bug or Feature request?:
Bug
## Steps to reproduce:
1. Create a new blazor project `dotnet new blazor`
2. Make a code change and verify the message "Code changes were successfully applied."
3. Switch back to the browser.
4. Observe that the browser is not automatically refreshed to reflect the changes.
5. Manually reload the page to see the applied changes.
## Description of the problem:
I tired the new experimental hot reload feature in C# Dev Kit. After making a code change and seeing the message "Code changes were successfully applied," the browser does not automatically refresh. The changes are only visible after manually reloading the page.
## Expected behavior:
The browser should automatically refresh to display the latest changes made in the code.
## Actual behavior:
The browser does not refresh automatically after code changes. The updated content is only visible after manually reloading the page.
## Logs
#### OmniSharp
------------------- Please fill in this section -------------------------
To find the OmniSharp log, open VS Code's "Output" pane, then in the dropdown choose "OmniSharp Log".
#### Razor
Expand
```
-- Starting Issue Data Collection--
provideCodeLens failed with Error: Illegal argument
provideCodeLens failed with Error: Illegal argument
72 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 16, synchronizing to version '16'.'
72 - Projected document in sync with host document
72 - Projected text document in sync with data type
72 - Synchronization successful!
73 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 16, synchronizing to version '16'.'
73 - Projected document in sync with host document
73 - Projected text document in sync with data type
73 - Synchronization successful!
74 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 16, synchronizing to version '16'.'
74 - Projected document in sync with host document
74 - Projected text document in sync with data type
74 - Synchronization successful!
75 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 16, synchronizing to version '16'.'
75 - Projected document in sync with host document
75 - Projected text document in sync with data type
75 - Synchronization successful!
76 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 16, synchronizing to version '16'.'
76 - Projected document in sync with host document
76 - Projected text document in sync with data type
76 - Synchronization successful!
77 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 16, synchronizing to version '16'.'
77 - Projected document in sync with host document
77 - Projected text document in sync with data type
77 - Synchronization successful!
78 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 16, synchronizing to version '16'.'
78 - Projected document in sync with host document
78 - Projected text document in sync with data type
78 - Synchronization successful!
79 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 16, synchronizing to version '16'.'
79 - Projected document in sync with host document
79 - Projected text document in sync with data type
79 - Synchronization successful!
80 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.html':
Currently at 16, synchronizing to version '16'.'
80 - Projected document in sync with host document
80 - Projected text document in sync with data type
80 - Synchronization successful!
81 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.html':
Currently at 16, synchronizing to version '16'.'
81 - Projected document in sync with host document
81 - Projected text document in sync with data type
81 - Synchronization successful!
Updating the HTML document for Razor file 'd:/Projects/Experimental/BlazorSSR/Components/Layout/MainLayout.razor' (17)
Notifying document 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor' changed 'htmlChanged'
Updating the C# document for Razor file 'd:/Projects/Experimental/BlazorSSR/Components/Layout/MainLayout.razor' (17)
Notifying document 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor' changed 'csharpChanged'
82 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 17, synchronizing to version '17'.'
82 - Projected document in sync with host document
82 - Projected text document not in sync with data type, waiting for update...
Current projected text document sync version: 16
82 - Projected text document synchronized to 17.
82 - Projected text document in sync with data type
82 - Synchronization successful!
83 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 17, synchronizing to version '17'.'
83 - Projected document in sync with host document
83 - Projected text document in sync with data type
83 - Synchronization successful!
Updating the HTML document for Razor file 'd:/Projects/Experimental/BlazorSSR/Components/Layout/MainLayout.razor' (18)
Notifying document 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor' changed 'htmlChanged'
Updating the C# document for Razor file 'd:/Projects/Experimental/BlazorSSR/Components/Layout/MainLayout.razor' (18)
Notifying document 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor' changed 'csharpChanged'
84 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 18, synchronizing to version '18'.'
84 - Projected document in sync with host document
84 - Projected text document in sync with data type
84 - Synchronization successful!
85 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 18, synchronizing to version '18'.'
85 - Projected document in sync with host document
85 - Projected text document in sync with data type
85 - Synchronization successful!
86 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.cs':
Currently at 18, synchronizing to version '18'.'
86 - Projected document in sync with host document
86 - Projected text document in sync with data type
86 - Synchronization successful!
87 - Synchronizing 'd:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor__virtual.html':
Currently at 18, synchronizing to version '18'.'
87 - Projected document in sync with host document
87 - Projected text document in sync with data type
87 - Synchronization successful!
-- Stopping Issue Data Collection--
```
## Workspace information
#### Razor document:
Expand
```Razor
@inherits LayoutComponentBase
```
#### Projected CSharp document:
Expand
```C#
////////////////////// Projected CSharp as seen by extension ///////////////////////
//
#pragma warning disable 1591
namespace BlazorSSR.Components.Layout
{
#line default
using global::System;
using global::System.Collections.Generic;
using global::System.Linq;
using global::System.Threading.Tasks;
using global::Microsoft.AspNetCore.Components;
#nullable restore
#line 1 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using System.Net.Http;
#nullable disable
#nullable restore
#line 2 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using System.Net.Http.Json;
#nullable disable
#nullable restore
#line 3 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using Microsoft.AspNetCore.Components.Forms;
#nullable disable
#nullable restore
#line 4 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using Microsoft.AspNetCore.Components.Routing;
#nullable disable
#nullable restore
#line 5 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using Microsoft.AspNetCore.Components.Web;
#nullable disable
#nullable restore
#line 6 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using static Microsoft.AspNetCore.Components.Web.RenderMode;
#nullable disable
#nullable restore
#line 7 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using Microsoft.AspNetCore.Components.Web.Virtualization;
#nullable disable
#nullable restore
#line 8 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using Microsoft.JSInterop;
#nullable disable
#nullable restore
#line 9 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using BlazorSSR;
#nullable disable
#nullable restore
#line 10 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using BlazorSSR.Components;
#line default
#line hidden
#nullable disable
#nullable restore
public partial class MainLayout : LayoutComponentBase
#nullable disable
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((global::System.Action)(() => {
#nullable restore
#line 1 "d:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor"
LayoutComponentBase __typeHelper = default!;
#line default
#line hidden
#nullable disable
}
))();
}
#pragma warning restore 219
#pragma warning disable 0414
private static object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
__builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => {
}
));
#nullable restore
#line 5 "d:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor"
__o = typeof(global::BlazorSSR.Components.Layout.NavMenu);
#line default
#line hidden
#nullable disable
#nullable restore
#line 14 "d:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor"
__o = Body;
#line default
#line hidden
#nullable disable
}
#pragma warning restore 1998
}
}
#pragma warning restore 1591
////////////////////// Projected CSharp as seen by extension ///////////////////////
//
#pragma warning disable 1591
namespace BlazorSSR.Components.Layout
{
#line default
using global::System;
using global::System.Collections.Generic;
using global::System.Linq;
using global::System.Threading.Tasks;
using global::Microsoft.AspNetCore.Components;
#nullable restore
#line 1 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using System.Net.Http;
#nullable disable
#nullable restore
#line 2 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using System.Net.Http.Json;
#nullable disable
#nullable restore
#line 3 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using Microsoft.AspNetCore.Components.Forms;
#nullable disable
#nullable restore
#line 4 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using Microsoft.AspNetCore.Components.Routing;
#nullable disable
#nullable restore
#line 5 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using Microsoft.AspNetCore.Components.Web;
#nullable disable
#nullable restore
#line 6 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using static Microsoft.AspNetCore.Components.Web.RenderMode;
#nullable disable
#nullable restore
#line 7 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using Microsoft.AspNetCore.Components.Web.Virtualization;
#nullable disable
#nullable restore
#line 8 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using Microsoft.JSInterop;
#nullable disable
#nullable restore
#line 9 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using BlazorSSR;
#nullable disable
#nullable restore
#line 10 "d:\Projects\Experimental\BlazorSSR\Components\_Imports.razor"
using BlazorSSR.Components;
#line default
#line hidden
#nullable disable
#nullable restore
public partial class MainLayout : LayoutComponentBase
#nullable disable
{
#pragma warning disable 219
private void __RazorDirectiveTokenHelpers__() {
((global::System.Action)(() => {
#nullable restore
#line 1 "d:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor"
LayoutComponentBase __typeHelper = default!;
#line default
#line hidden
#nullable disable
}
))();
}
#pragma warning restore 219
#pragma warning disable 0414
private static object __o = null;
#pragma warning restore 0414
#pragma warning disable 1998
protected override void BuildRenderTree(global::Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
{
__builder.AddAttribute(-1, "ChildContent", (global::Microsoft.AspNetCore.Components.RenderFragment)((__builder2) => {
}
));
#nullable restore
#line 5 "d:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor"
__o = typeof(global::BlazorSSR.Components.Layout.NavMenu);
#line default
#line hidden
#nullable disable
#nullable restore
#line 14 "d:\Projects\Experimental\BlazorSSR\Components\Layout\MainLayout.razor"
__o = Body;
#line default
#line hidden
#nullable disable
}
#pragma warning restore 1998
}
}
#pragma warning restore 1591
// 18
```
#### Projected Html document:
Expand
```Html
////////////////////// Projected Html as seen by extension ///////////////////////
/*~~~~~*/ /*~~~~~~~~~~~~~~~*/
////////////////////// Projected Html as seen by extension ///////////////////////
/*~~~~~*/ /*~~~~~~~~~~~~~~~*/
// 18
```
## Machine information
**VSCode version**: 1.97.2
**Razor.VSCode version**: 2.63.32
#### `dotnet --info`
Expand
```
.NET SDK:
Version: 9.0.200
Commit: 90e8b202f2
Workload version: 9.0.200-manifests.c4f6226a
MSBuild version: 17.13.8+cbc39bea8
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.200\
.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.2
Architecture: x64
Commit: 80aa709f5d
.NET SDKs installed:
9.0.200 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
```
#### Extensions
Expand
|Extension|Author|Version|
|---|---|---|
|copilot|GitHub|1.272.0|
|copilot-chat|GitHub|0.24.1|
|csdevkit|ms-dotnettools|1.16.6|
|csharp|ms-dotnettools|2.63.32|
|vscode-dotnet-runtime|ms-dotnettools|2.2.8|;
Contributor guide
Assessment
This issue has not been assessed yet.