Today we're releasing a nifty project dubbed ConsolR. ConsolR is a console that you add to an ASP.NET web application to let you run arbitrary C# from within the app. This means that everything that's available to your application (or your application's AppDomain to be more precise), will be available from ConsolR as well. This allows you to execute code on-the-fly from a browser using C# in your application's environment, which is useful for numerous use cases.
The tool is mostly intended for debugging applications as it provides access to the application's state. It's also a convenient way to access a production server's dependencies such as external databases, caching and logging services, which may not always be accessible from the developer's own machine. All namespaces, classes and so forth that are available for your application can be called from ConsolR.
In this screenshot you can see an example of how ConsolR works when it is installed on an application that uses Entity Framework. On the left hand side a database context is initialized so we can loop over the users in the database. ConsolR uses SignalR to communicate with the web server, so we can use that channel to "log" messages back to the browser.
If you're familiar with Compilify by Justin Rusbatch you'll find that it works and looks pretty much the same. This is no coincidence. The entire project is based on Compilify and is essentially a stripped down and re-purposed version with fewer dependencies. On top of that some auto-registration of the required routes and http handlers happens when the application starts, so you don't have to do anything to wire it all up.
Installing ConsolR is really simple. We've packed everything up in a NuGet package, simply run
Install-Package ConsolR to install it. ConsolR will register itself and be available under the "/consolr" path (default username/password is "foo"/"bar"). All of this is of course configurable. Make sure to add the new files in the /assets directory to your version control system and you're ready to go. If you have enabled NuGet package restore you don't need to include the ConsolR package and binaries.
ConsolR is designed to work with all types of .NET 4.0 web applications, including MVC, ASP.NET Web apps, Nancy projects etc.
The project is released under the MIT license and we're happy to accept contributions. ConsolR is an early alpha release and usage of it is your own risk. Read more about ConsolR and get the source code on the project page