View code changes without restarting the server

We use Visual Studio and DNX code as follows.

Command line to start the web server

dnx . web 

project.json> teams

 "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001" 

Please note that we added carriages for readability.

When *.cshtml and the browser is updated, the changes are displayed in the browser. It's good.

When we change a *.cs and update the browser, the changes are not displayed in the browser. We expected them to do this. To see the changes, we need to stop the web server (with Ctrl + C on the command line) and then start it again using dnx . web dnx . web .

This is not the end of the world; what I said that one of the features of ASP.NET 5 is the ability to update without recompiling, etc.

How can we change the *.cs code and update the browser to view the changes without restarting the DNX web server?

We tried to run dnx --watch . web dnx --watch . web with the problem that if we change the *.cs file, the web server will stop, and we still need to restart it.

+5
source share
3 answers

This is the expected behavior. You can use something like gulp-aspnet-k to automate this process. More information is available here: Create and run your ASP.NET vNext application using Gulp .

Note that this gulp integration unfortunately only works on Windows now , but all it does is look at the dnx process and restart it again .

+1
source

The change code on the fly only works when run without debugging . I assume that you just press F5 (debug) from VS, which actually attaches the debugger. Try it and it should work.

In short: to update the code, the server must reboot. When starting from the command line, the server stops and never reboots - you should handle this yourself, as suggested by @tugberk, but when starting from VS, the toolkit will take care of this for you.

+5
source

You can use the dnx-watch command for this. It did not exist when the original question was asked, but was added to beta 8 in September 2015. You install it with

The dnu commands install Microsoft.Dnx.Watcher. You run it by simply passing it the command that you would pass dnx to. So replace

 dnx web 

from

 dnx-watch web 

You can find out more here: http://ardalis.com/get-started-with-dnx-watch

+1
source

All Articles