Why does page not update after refresh when .cshtml changes - asp.net-core

I am trying out Blazor and i do not understand why when changing a component after refreshing the browser page it does not update ? Shouldn't the client update itself similar to how angular does?
It only refreshes when i restart the blazor server.
Index.cshtml
#page "/"
<h1>Hello, world!</h1>
If i change lets say the text inside the <h1> to Hello people , i save the project and i refresh the page ( as i am advised in the Blazor tutorial) shouldn't i see Hello people ?

After Asp.net Core 3.0, Runtime compilation is enabled using the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package.
To enable runtime compilation, apps must:
Install the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet package.
Update the project's Startup.ConfigureServices method to include a call to AddRazorRuntimeCompilation:
services
.AddControllersWithViews()
.AddRazorRuntimeCompilation();
or
services.AddMvc().AddRazorRuntimeCompilation();

I guess you are running the app with the debugger connected? this prevents the recompilation. You need to:
Press Ctrl-F5 to run the app without the debugger. Running with the debugger (F5) isn't supported at this time.
https://github.com/dotnet/aspnetcore/issues/5456

You should add or enable runtime compilation in razor pages,
Install-Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -Version 3.1.6
After installing set the startup file as ,
services.AddMvc().AddRazorRuntimeCompilation();

do the following:
Install the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation from NuGet.
Update the ConfigureServices method in the Startup class to look like below:
services.AddControllersWithViews().AddRazorRuntimeCompilation();
You good to go.

If you go into Tools > Options > Keyboard and search in the "Show commands containing" search box search for "BrowserLink". Find the option that says "OtherContextMenus.BrowserLink.RefreshLinkedBrowsers" by default this is set to CTRL+Alt+Enter. Click "Remove" and then select the "Press Shortcut Keys" input and press Ctrl+S. Next (just to the left of the input) change Use new shortcut in "Global" to be "Text Editor". Click "Ok" until the window has closed. Now Visual Studio shares CTRL+S with both Saving files and Refreshing linked browsers.
(This will only work if your text editor .cshtml, .css, .js, etc. files in the edit window are the active selections) WARNING: if you don't set it to something other than global then it will override the shortcut for Save and you won't be able to save your files.

Adding "services.AddMvc().AddRazorRuntimeCompilation();" and installing the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package 6.0.5 will fix the problem but it will ruin the "css isolation". The first thing you will notice is that the footer will lose its position

Related

Visual Studio 2019 QuickWatch displays Unable to evaluate (Unable to evaluate) in ASP.NET Core Blazor WebAssembly Program.cs File

I'm trying to debug and evaluate expression in my blazor wasm Program.cs using QuickWatch in my Visual Studio 2019. To make the breakpoint hit in Main method, I added
await Task.Delay(10000);
this gives debugging proxy some time to load as mentioned in docs.
Now after my break point gets hit if I select any expression and press Shift+F9 to toggle QuickWatch, I get
Unable to evaluate (Unable to evaluate)
for any variables, expression. Please assist on what I'm missing
Screen Print:
Currently Blazor WebAssembly does not support hitting breakpoint the Program > Main method inside Program.cs. Below is from Microsoft docs:
For now, you can't:
Break on unhandled exceptions.
Hit breakpoints during app startup before the debug proxy is running. This includes breakpoints in
Program.Main (Program.cs) and breakpoints in the
OnInitialized{Async} methods of components that are loaded by the
first page requested from the app.
For me it was an upgrade issue from DotNet Core 3.x to 5.0.
It is a good idea to create a completely new Blazor Application with identical configuration and compare all project files. In my case it was an entry in {MyProject}.Server.csproj of:
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.1" />
that needed to be updated to the latest version:
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="5.0.4" />
Everything worked fine to run and breakpoints were hit but until I changed that line all variables would show "Unable to evaluate (Unable to evaluate)" in Quickwatch and hovering in the editor showed nothing.

Configure an existing theme on Shopify

I'm totally new with Shopify, im trying to Configure an existing theme and fallow the full process form the guideline here (https://shopify.github.io/themekit/) but when I try to run the command theme download it shows me the error
requested theme was not found
though I setup Private apps and configure everything
so is there anything that I missed out of the box.
First of all try to grab Correct ID of your Store from here: https://www.screencast.com/t/ZySPCKUTi
https://www.screencast.com/t/If0MHah3
And run CMD Command from your destination folder path.
This error is showing when you use the wrong theme ID, check it.

Remove weatherforecast default route

I have started a default .Net Core WebAPI project using the 3.0 preview 8. I have removed the default weatherforecast controller from the project, and added my own controller. However, starting the project always defaults to the route https://localhost:44380/weatherforecast. I can not find the setting to change this. How do I set the default controller in .Net Core 3?
In Solution Explorer, click the "Show all Files" button.
It will show the Properties pseudo-folder. In launchSetting.json the startup url is configured.
You could also right click your project -> Select Properties -> Select the Debug tab on the left -> Then edit the 'Launch browser' field to set your own default launch url.
Applies for docker
Since the OP has mentioned docker.
Just to append a bit to the answer.
Changing the Launch settings is correct, although there is a case where it might not work.
I recently came upon this issue and even though my launchsettings were correct I was still directed to the weatherforecastroute.
The reason for this was in my docker-compose.dcproj the XML property DockerServiceUrl
was still pointing to the {Scheme}://localhost:{ServicePort}/weatherforecast. I needed to update the value there as well.
For Visual Studio 2022, Project, Properties, Debug, then link: Open debug lauch profile. Set the Url as u like
On Visual Studio for Mac
Right click your Project -> Select Options ->
Select Run -> Configurations -> Default tab on the left ->
Select Asp.Net Core Tab -> unselect Open URL in web browser when app starts checkbox

Sublime Text 2 and ZF2 ... auto complete not works

I installed sublime text 2 with all php dependencies.
And also a package for code complete called sublimecodeintel.
There is not zf2 supported auto code complete.
For example, when I start writing
\Zend\Form\...
at each steps CTRL+Space does not give any subclasses of Form
or for example after this:
$testimonial = new \Application\Entity\Testimonial();
when I write this:
$testimonial->
CTRL+Space shows a list but there is no methods listed from Testimonial php class.
Please help.
You might need to add the path to the ZF2 folder if they aren't in one of the project folders, or you could add a .codeintel/config file to your project root and add:
{
"PHP": {
"php": '/usr/bin/php',
"phpExtraPaths": ['path/to/ZF2'],
"phpConfigFile": 'php.ini'
}
}
So make sure you have the paths set up correctly, and it should work.
Also SublimeCodeIntels default mappings for autocomple is:
Linux: shift+ctrl+space
Mac: shift+super+space
Windows: shift+ctrl+space
Sublime Text 2 is not an IDE and so does not have autocomplete. You could try installing the SublimeCodeIntel package and see if that works for you.
Alternatively, consider NetBeans, PHPStorm, Zend Studio or Eclipse/PDT which are all IDEs that understand how to do auto complete with PHP.

how to use glimpse with petapoco?

I installed this plugin from nuget.
I enabled glimpse through the glimpse.axd file but when I go to the petapoco tab I see this message
"No database requests or database logging not switched on (Compilation debug='true' or ForceLogging='true' on PetaPoco.DatabaseWithLogging)"
where do I set this logging?
You need to create a new DatabaseWithProfiling() not Database() as you normally would. Checkout out the code in the Model folder after you have pulled it down from NuGet.