question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hot Reload not working with Razor cshtml in Azure Functions

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I am using RazorViewEngine inside azure function instances to render content. The heart of it is in a FunctionsStartup:

        var partFactory = ApplicationPartFactory.GetApplicationPartFactory(Assembly.GetExecutingAssembly());
        var mainViewAssemblyApplicationParts = partFactory.GetApplicationParts(Assembly.GetExecutingAssembly());

        builder.Services
            .AddSingleton<IStringLocalizerFactory, ResourceManagerStringLocalizerFactory>()
            .AddMvcCore()
            .AddViews()
            .AddRazorViewEngine()
            .ConfigureApplicationPartManager(
                manager => {
                    foreach (var p in mainViewAssemblyApplicationParts)
                    {
                        manager.ApplicationParts.Add(p);
                    }
                }
            )

and i set my SDK <Project Sdk="Microsoft.NET.Sdk.Razor"> and <AddRazorSupportForMvc>True</AddRazorSupportForMvc>

this works real well…and hotreload works for .cshtml.cs files…but it doesn’t seem to work for .cshtml files…my changes are just ignored.

Expected Behavior

i expect to be able to make changes to chstml files save, invoke hot reload, refresh my page and see changes.

Steps To Reproduce

see bug description for code

Exceptions (if any)

No response

.NET Version

6.0.201

Anything else?

vs 2022

Azure Functions Core Tools Core Tools Version: 4.0.4385 Commit hash: N/A (64-bit) Function Runtime Version: 4.1.3.17473

Microsoft Visual Studio Professional 2022 Version 17.1.0 VisualStudio.17.Release/17.1.0+32210.238 Microsoft .NET Framework Version 4.8.04084

Installed Version: Professional

ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools

ASA Service Provider 1.0

ASP.NET and Web Tools 2019 17.1.358.51495 ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019 17.1.358.51495 For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 17.1.358.51495 Azure App Service Tools v3.0.0

Azure Data Lake Tools for Visual Studio 2.6.5000.0 Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 17.1.358.51495 Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.6.5000.0 Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools 4.1.0-5.22109.6+0c82c4114a4e4b8b723b915eee3b13261db6717f C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events

Microsoft Azure Hive Query Language Service 2.6.5000.0 Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio 17.0 Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service 2.6.5000.0 Language service for Azure Stream Analytics

Microsoft Azure Tools for Visual Studio 2.9 Support for Azure Cloud Services projects

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 2.1.161+abc97ecc7d.RR Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers 1.2 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

NuGet Package Manager 6.1.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Razor (ASP.NET Core) 17.0.0.2206201+62a2c1d6162f828801565a7ca26d9d48b810a05b Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools 17.0.62201.12090 Microsoft SQL Server Data Tools

ToolWindowHostedEditor 1.0 Hosting json editor into a tool window

TypeScript Tools 17.0.1229.2001 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.1.0-5.22109.6+0c82c4114a4e4b8b723b915eee3b13261db6717f Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 17.1.0-beta.21610.4+07b5673e4f2fa7630e78abe37f16b372353a7242 Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions 1.0 View, manage, and diagnose containers within Visual Studio.

Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio.

Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
drdamourcommented, Mar 17, 2022

@TanayParikh this is NOT a dupe of that issue. In that issue the change is present after a refresh…it just doesnt auto refresh. In this issue the change isnt present even after a refresh.

please reopen.

0reactions
drdamourcommented, Mar 23, 2022

triage process dcs don’t explain if it’s been decided if this is a understood/acknowledged issue and that there’s no solution or if there is something i as a consumer can do to work around this. Is there such a determination being made?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hot Reload not working in Visual Studio 2022 .Net 6 Razor ...
Refreshing the page doesn't seem to show the updates either. The ASP.NET Core 3.1 project hot reload is working as expected. When we...
Read more >
NET Hot Reload support for ASP.NET Core
NET Hot Reload applies code changes, including changes to stylesheets, to a running app without restarting the app and without losing app state....
Read more >
Write and debug code by using Hot Reload - Visual Studio ...
Update running code with Hot Reload · Open a project based on a supported application type. · Make sure that Enable native code...
Read more >
Update on .NET Hot Reload progress and Visual Studio ...
For .NET MAUI Blazor apps Hot Reload will not yet automatically refresh the view and CSS Hot Reload is not yet available. These...
Read more >
Razor file compilation in ASP.NET Core
Razor files with a .cshtml extension are compiled at both build and publish time ... We recommend using Hot Reload instead of Razor...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found