Visual Studio 2020 Hot Reload isn't working - visual-studio

I am using Visual Studio 2022 v 17.2.1 to create an ASP.NET Core/6 app.
When I make HTML only changes to my Razor Views, and I try to hot reload the page, I get the following
Here are my Hot-Reload settings
How can I get the Hot-Reload function working so I don't have to restart my app every time I want to see the change in the browser?

One possibility is that you are using Response Compression Middleware (UseResponseCompression()) in the Program.cs file.
It seems that this middleware is no longer needed for Blazor Webassembly, and that for some people removing the installation of the middleware UseResponseCompression() fixes the problem of getting an error when attempting to hot reload. Some Microsoft documentation says to use the compression middleware, but this breaks the hot reload functionality, in my exprience. Once this call is removed, hot reload works for running with the Debugger attached and not attached.

Related

Blazor Interopt Js in separate project doesn't refresh, even by removing cache, bin/obj

This is a cache issue I guess. Let me explain,
I have a .net6 blazor project (client server and shared project) which as a referenced project call ReactorBlazorMapbox (Razor library), which is in charge with JsInterop to play with mapbox js.
Code in progress, but works great yet. Display a map, display popup...
The ReactorBlazorMapbox project has its own JS file, called MapboxInterop.js. This file is loaded in ./_content/ReactorBlazorMapbox/MapboxInterop.js
This way, no need to reference the file in the client projet. It's embeded. Great.
My problem is, when I modify this file, nothing happend. Clear cache CTRL-F5, manualy clearing cache using inpector/Application/Cache/Delete (or local/session storage). I also removed bin/obj, clean solution, re generate projects on C# side.
My MapboxInterop.js in the browser does not refresh. (using inspector/Source)
I had to rename it MapboxInterop2.js and change my link in the import, this way it works. At least one time. But add a new file each time modification is done in this file will be time killer...
I found a work around, instead of using a embeded js interopt file from the side project, I put this one in the Blazor Client /wwwwroot/js path and add this line :
//load js from client projet path
_Module = await _JsRuntime.InvokeAsync<IJSObjectReference>("import", "./js/MapboxInterop.js");
instead of
//load js from this project
_Module = await _JsRuntime.InvokeAsync<IJSObjectReference>("import", "./_content/ReactorBlazorMapbox/MapboxInterop2.js");
this way, when re running the site with VS2022, the file in cache is refreshed.
If someone has an idea so the same thing happen for a embed project js...
FCK me :)
I forgot to check "disable cache" checkbox in the browser inspector.
But, there is a cache difference between those two files. (client vs project)...

Correctly clearing cache in Umbraco 7

To be honest, I've no idea how Umbraco handles clearing its cache. I'm currently developing a property editor, and I'd like to see the result of my changes in the content section. However whenever i save my changes, build the project and refresh the page, nothing has changed.
I've tried deleting the cache folder, changing the web.config file, installing a special chrome extension to do a hard reset, clearing the entire cache, closing and opening Visual Studio and nothing seems to make any difference.
How can I make Umbraco update its cache to reflect the changes I've made to a property editor in the content section?
Umbraco joins all of the required assetts together using the Client Dependency Framework. These are then cached and stored at \App_Data\TEMP\ClientDependency\.
You can just delete these to refresh the cache.
You can stop Umbraco from doing using the CDF by putting your application in debug mode. In your Web.config, find the compilation item and change debug to equal true:
<compilation defaultLanguage="c#" debug="true" batch="false" targetFramework="4.5">
When Umbraco is set to debug mode false, calls like this will be done which get the cached version of assets: /DependencyHandler.axd?s=
When Umbraco is in debug mode, direct calls to your custom assets (and any others that are needed) will be made.
You will also need to hard refresh your browser like you were doing before or your browser may locally cache the files too.
Have you tried adding a query string to the end of the URL? Inside the plugin package.manifest your can add a random query string at end of the urls so the browser needs to re cache that url
eg. "~/App_Plugins/Javascript Url" + "?v=123432asdsa"

Sharepoint 2010 WSP deploy wont update site

Im not very used to the whole Sharepoint-thing, but usually I just simply deploy my visual studio stuffs as a wsp-package and then deploys it using PS (if I dont remember incorrect)..
Now this time I wanted to update the masterpage of my site, and add a few javascript files and update an existing javascript file.. and this time for some reason the deploy did update the allready existing javascript-file, but it didnt add the new javascriptfiles..and it didnt update the masterpage for some reason.. and I have dubble-checked that the package Im depolying contains the new files and the updated masterpage, I also checked the Elements.xml-file for the javascript files and they are there.. Any ideas?
Check if you files are customized from definition (in SharePoint Designer they will have an (i) symbol. If so - revert them to definition and try to deactivate the feature again.

CSS file not updating on Azure Deploy/Publish

RESOLVED
Unbeknownst to me, Cloudflare defaults to caching all css/js files for 4 hours.
Scenario:
I add this to our front page:
<span class="test">hullo!</span>
and this to our css file:
.test { font-size:2.0em; }
I do a web deploy, OR full publish to Azure and the span appears on the front page, but not the styling. The css file for some reason does not get updated. FF, IE, Chrome and Safari all confirm it. However, after a seemingly arbitrary time, the css file get updated.
Even when I remote into the Azure VM and restart the app, the styling is unchanged. The app is running on one instance, one role. No Azure Caching is setup. Adding a querystring param to the css file link does not help. Seems like a caching issue but no clue how to resolve.
Any ideas?
"We are using Cloudflare which has a default set up to cache all CSS and JS files. It purges the cache every 4 hours which resulted in the arbitrary updates. So, even though I was adding a new query string to the end of the css file, Cloudflare still cached the old one"
Just a quick note that you should go to CloudFlare Development Mode when making changes to the static content files on your site. You can get to Development Mode to bypass the cache by going to: settings->Development Mode. You also have the option of purging your cache as an additional option, which we would only recommend if you really want to purge everything.
Looks like it's cached by your browser. Can you please try navigate to your site and press Ctrl+F5.
Maybe you can use Fiddler to see if the CSS had been cached, or not updated, or some error when download.
This issue is resolved.
We are using Cloudflare which has a default set up to cache all CSS and JS files. It purges the cache every 4 hours which resulted in the arbitrary updates. So, even though I was adding a new query string to the end of the css file, Cloudflare still cached the old one.
I have dealt with this and I will tell you that from my experience in Chrome you can set a setting that disables the cache in the developer tools, however, I've noticed that unless you have the dev tools window open when you hit Ctrl+F5 it doesn't reload the cache. In IE there is a global setting in the dev tools that will make it redownload everything every time. In Firefox there is also a setting in the dev tools that will require it to download and not use the cache.
One way that you can test this, and how I test this, is by running Fiddler and watching if it does a full download of all your files or if it's caching.
From what I've experienced is that this is truly a browser caching issue and not anything to do with Azure.

MVC3 Global.asax.cs events not firing in local IIS

I have an MVC3 application, trying to register/run this in IIS (6.1 and 7.5 Express) so I can run it as a local server and debug it via VS2010. For some reason the events in the Global.asax.cs file are not firing. Namely Application_Start so consequently, the RegisterRoutes is also not being called.
I use Re-sharper and it's telling me Application_Start() is never used which is strange as when I use the ASP.NET local web server (Project Properties, Use Visual Studio Development Server) this is called and executed as expected.
The problem seems to lie with running the app via IIS??
The file is a .cs file so I tried creating a Global.asax and inheriting the Global.asax.cs as per code behind. I also looked in IIS Manager > Handler Mappings > ExtensionlessUrlHandler-ISAPI-4.0_64bit thinking along the lines of the MVC routing - still, I cannot find a solution here either.
I've had a dig through posts on here and asked Google but failed to come up with a solution. Any other ideas?

Resources