1

I am new to the asp.net MVC concept and project design, i'm at early learning stage.

i'm using visual studio 2019 | project type : asp.net MVC (.net framework)

i want to know how to deploy my application for viewing live-changes, like there is an with node.js live-server extension we can use (localhost:8080) to track live changes in html,css,js whenever we save these file browser automatically reloads and we can see the changes.

how can i do it for the asp.net MVC application as it has such complex architecture?

if i run the IIS Express which is default, it does not automatically reloads when content changes, file is saved and it open the visual studio debugging mode which is pretty annoying to work with.

there are extension like BrowserLinkLivePreview but it does not auto reloads the main page (index.html) when any of the file's code is changed and saved.

Hassaan Raza
  • 187
  • 3
  • 12
  • Does this answer your question? [Live reload with Asp.Net 5](https://stackoverflow.com/questions/33034169/live-reload-with-asp-net-5) – MindSwipe Oct 06 '20 at 07:26
  • no both the answer did not help in auto reload of the browser, i still have to click the reload manually. – Hassaan Raza Oct 06 '20 at 08:30

2 Answers2

1

I am using this tool: https://marketplace.visualstudio.com/items?itemName=MadsKristensen.BrowserReloadonSave. It works on VS 2019 Community.

You can see here how to set up Browser Link in ASP.NET Core ("You can use Browser Link to refresh your web app in several browsers at once..."):

https://learn.microsoft.com/en-us/aspnet/core/client-side/using-browserlink?view=aspnetcore-3.1

Browser Link setup:

Add the Microsoft.VisualStudio.Web.BrowserLink package to your project. For ASP.NET Core Razor Pages or MVC projects, also enable runtime compilation of Razor (.cshtml) files as described in Razor file compilation in ASP.NET Core. Razor syntax changes are applied only when runtime compilation has been enabled.

Configuration:

Call UseBrowserLink in the Startup. Configure method:

app.UseBrowserLink();

The UseBrowserLink call is typically placed inside an if block that only enables Browser Link in the Development environment. For example:

if (env.IsDevelopment())    
{    
    app.UseDeveloperExceptionPage();    
    app.UseBrowserLink();    
}
TsvetiZlateva
  • 121
  • 1
  • 6
0

I add temporarily javascript in cshtml to reload every few seconds, since no

<script>
    setTimeout(function () { window.location.reload(); }, 4000);
</script>
yu yang Jian
  • 6,680
  • 7
  • 55
  • 80