I have created one console application in asp.net core in window PC and create a.sln file(vs 2017). Now, I will need to run the same.sln file on Linux / Mac visual studio 2017. It’s available as a preview release as part of Visual Studio CTP 6, and offers a number of fairly significant changes, including the ability to run on Windows, Mac or Linux using the.NET Core. Hey, I've just installed Visual Studio for Mac, and can't find.NET Core(ASP.NET Core) I can see just.NET and ASP.NET MVC, ASP.NET Web Forms and Empty ASP.NET Project.
In this tutorial we are going to create a simple ASP.NET 5 web application on Mac, use SignalR to push events from server to connected clients and then deploy to Azure through a git repository.
What is ASP.NET 5?
ASP.NET 5 is a new open-source and cross-platform framework for building modern cloud-based Web applications using .NET. It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions.
In short, with ASP.NET 5 you gain the following fundamental improvements:
- New light-weight and modular HTTP request pipeline
- Ability to host on IIS or self-host in your own process
- Built on .NET Core, which supports true side-by-side app versioning
- Ships entirely as NuGet packages
- Integrated support for creating and using NuGet packages
- Single aligned web stack for Web UI and Web APIs
- Cloud-ready environment-based configuration
- Built-in support for dependency injection
- New tooling that simplifies modern web development
- Build and run cross-platform ASP.NET apps on Windows, Mac and Linux
- Open source and community focused
For more details, you can visit this page.
Installing ASP.NET 5
In order to install ASP.NET 5 and start working on Mac you have two options:
- Install ASP.NET 5 with Visual Studio Code
- Install Mono for OS X (required by Visual Studio Code)
- Install Visual Studio Code
- Install ASP.NET 5 for Mac OS X
- Install ASP.NET from the command-line
- Run the following
curl
command, to install .NET Version Manager (DNVM)
curl-sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh - Run
dnvm list
to show the DNX versions installed - Use DNVM to install DNX for .NET Core:
dnvm upgrade-rcoreclr
- Run the following

Yeoman and generator-asp.net
Yeoman helps you kickstart new projects, prescribing best practices and tools to help you stay productive. To do so, it provides a generator ecosystem. A generator is basically a plugin that can be run with the yo
command to scaffold complete projects or useful parts.
To kickstart a new ASP.NET 5 app, you need to install the generator-aspnet, as per the following steps:
npm install -g yo
to install Yeomannpm install -g generator-aspnet
to install a new project generator for ASP.NET apps- Run:
yo aspnet
to start with a new ASP.NET App- select Web Application
cd
to the new app folderdnu restore
to restore web app’s NuGet packages
Start you application
In order to start the application that has been generated through Yeoman, you need to run the dnx web
command.
The web
command has been defined in the project.json
file, the role of which is to:
- define package metadata,
- state project dependencies, and
- declare which frameworks the app will be built for.
If you point your browser to http://localhost:5000
you will see a simple “Hello World” page.
SignalR
ASP.NET SignalR is a library for ASP.NET developers that simplifies the process of adding real-time web functionality to applications. Real-time web functionality is the ability to have server code push content to connected clients instantly, as it becomes available, rather than having the server wait for a client to request new data. SignalR uses the WebSocket transport where available, and falls back to older transports where necessary.
You can read more details on SignalR here.
To add SignalR in your web application, you need to add the following dependencies in the project.json
file.
2 4 6 8 | <configuration> <add key='aspnetmaster'value='https://www.myget.org/F/aspnetmaster/api/v3/index.json' /> <add key='AspNetVNext'value='https://www.myget.org/F/aspnetvnext/api/v2' /> <add key='nuget'value='https://api.nuget.org/v3/index.json' /> </configuration> |
After specifying NuGet package sources, re-run dnu restore
to restore packages defined in your project.json
file.
Register SignalR
To make SignalR available in your application, you need to register it in your Startup file.
2 4 | <script src='https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js' asp-fallback-src='~/lib/jquery/dist/jquery.min.js' <script src='~/lib/signalr/jquery.signalR.js'></script> |
signalr/hubs
script is generated dynamically by the runtime on the first request and then cached.
Install Mvc 5 On Visual Studio 2015
These references must be included in this order: jQuery first, SignalR core after that, and SignalR proxies last.
Connect to SignalR server and request messages
Now, you need to connect to SystemHub and request a server generated message:
In Index.cshtml
file you add the following script:
2 4 6 8 10 12 14 16 | // This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 publicvoidConfigureServices(IServiceCollection services) // ... other configuration services.AddMvc(options=> if(!_env.IsDevelopment()){options.Filters.Add(newRequireHttpsAttribute());} { }); |
The source code for this tutorial, with slight modifications, can be found in my GitHub profile in 01.insights-signalr branch