We're using Visual Studio Code and DNX as follows.
Command Line to Start Web Server
dnx . web
project.json > commands
"web": "Microsoft.AspNet.Hosting
--server Microsoft.AspNet.Server.WebListener
--server.urls http://localhost:5001"
Note that we added carriage returns for readability.
When we change a *.cshtml
and refresh the browser, the changes show up in the browser. This is good.
When we change a *.cs
and refresh the browser, the changes do not show up in the browser. We expected that they would. To see the changes, we need to stop the web server (with Ctrl + C
in the command line) and then start it again with dnx . web
.
This isn't the end of the world; that said, I thought one of the features of ASP.NET 5 was the ability to refresh without recompiling etc.
How can we change *.cs
code and refresh the browser to see the changes without having to restart the DNX web server?
We have tried running dnx --watch . web
with the problem that, if we change a *.cs
file, then the web server stops and we must restart it anyway.
The change code on the fly feature works only when running without debugging. I assume you just press F5 (debug) from VS which actually attaches a debugger. Try without and it should work.
Long story short: in order to refresh the code behind, the server has to restart. When running from the command line, the server stops and never restarts - you have to handle that yourself, like @tugberk suggested - but when running from VS, tooling takes care of that for you.
This is the expected behavior. You can use something like gulp-aspnet-k to automate this process. More detailed info available here: Building and Running Your ASP.NET vNext Application with Gulp.
Note that this gulp integration unfortunately only works on Windows now but all it does is to watch the dnx process and restart it again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With