A web server for ASP.NET 5 that runs without debugging

Sorry if this is a stupid question, but I don't get it. So I created an ASP.NET 5 page using Visual Studio 2015 and DNX.

Out of the box, I have these two dependencies in my .json project:

"Microsoft.AspNet.Server.IIS": "1.0.0-beta4", "Microsoft.AspNet.Server.WebListener": "1.0.0-beta4" 

In the "commands" section of project.json, I have the following:

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

In the project properties, I can change profiles between "IIS Express" and "web" as deployment parameters. Both work fine when I start debugging, it starts the web server (either IIS Express or WebListener) and the site works. If I stop debugging, the server will stop. WebListener opens "dnx.exe" on the command line.

This plugin server level is really good, I understand. But how do I, as a developer, set up a simple server, where can I make changes to my site and quickly see the changes? I can, of course, install IIS and create a site that points to my wwwroot, but is this my only option in the ASP.NET world? Is it possible to run WebListener in the background (without showing me the command line with dnx.exe)? I can also start the node server, but again - this is great that I can, but why should I, when I have the full ASP.NET toolkit?

ASP.NET 5 has dynamic compilation , but I'm not sure how to test it, since my web server only runs in debug mode.

I know this is a preliminary release, but any help would be greatly appreciated.

+6
source share
1 answer

But how do I, as a developer, set up a simple server on which I can do go to my site and quickly see the changes.

Regardless of the server you are using, you can use dynamic compilation by running the project without debugging (Shift + F5).

Due to architectural reasons, dynamic compilation does not work when starting from debugging (F5) in Visual Studio. This is due to the fact that the difference between Shift + F5 and F5 is that in the latter VS attaches the debugger to the process.

Will all this be supported in the future? This is unclear, but right now, because VS is not smart enough to handle disconnecting from a process, expecting dnx to dynamically recompile and then reconnect to the process. However, so far he has never had a reason to support such a scenario, so it is unclear whether it is simply β€œhe does not yet know how to do this” or β€œit is impossible to do”.

I can, of course, install IIS and create a site that points to my wwwroot, but is this my only option in the ASP.NET world?

No. You can use any web server that supports Microsoft.AspNet.Hosting. Today, your choice is limited to IIS, IIS Express, and the two experimental servers you are tied to, but the goal is to allow third-party developers to develop alternatives by providing a programmable interface (Microsoft.AspNet.Hosting).

ASP.NET 5 has dynamic compilation, but I'm not sure how to check it since my web server only starts in debug mode.

If the web application is running, the server starts. No web server = no ASP.NET application. I assume that "debugging mode" means "Start with debugging (F5)." If yes, then "Start without debugging (Shift + F5)" to fix the problem you are facing.

Here is an exercise:

  • Close Visual Studio (not necessary, but it is useful to show that none of this depends on VS).
  • Launch the web server. The easiest way is dnx. Web run from the command line in the project root folder. However, you can start IIS Express (should already be configured) or even configure IIS and start it.
  • Make sure that the web server and web application are running by opening it in a browser.
  • Using notepad or some other text editor, edit the file in the project, which will have a visible change or just throw the error "throw new NullReferenceException ()".
  • Save the file.
  • Refresh browser.

The web application will reflect the changes. You may notice a slight delay if you update quickly. This is a dynamic memory compilation.

+6
source

Source: https://habr.com/ru/post/989160/


All Articles