Recently Microsoft announced new version of Asp.Net Core and that is Asp.Net Core 2.0 which has new and amazing features which not only improve performance as well as increase productivity and enhance you application more robust and reliable.
You can use Asp.Net Core 2.0 with Visual Studio 2017 version 15.3. To use .Net Core 2.0 features, First you can .NET Core SDK 2.0 and then upgrade Visual Studio 2015 or 2017 using “Visual Studio Installer” with .Net Framework 4.6 and higher version Or you can do fresh installation of Visual Studio 2017 version 15.3 and must select .Net Framework 4.7.
To create new project in Asp.Net Core MVC 2.0 with Visual Studio 2017 version 15.3, you have follow below steps.
- Go to File menu and click to New and then choose Project.
- From the New Project window, first you have to choose .Net Framework 4.6 or above version and then from the left panel, choose Visual C# and then .Net Core.
- Now in right panel, you will see different kinds of project template; here you have to choose “Asp.Net Core Web Application”.
- To save your project, provide the valuable name and location and click to OK.
- Next window will provide you different types of template to create web application and these are as following.
- Empty Template for basic configuration.
- Web API for creating Rest API
- Web Application to create Razor Pages Application
- Web Application (Model-View-Controller) to create Asp.Net Core MVC 2.0 application
- Angular to create SPA application with Angular 2 or above version
- React.js to create SPA application with React.js
- React.js to create SPA application with React.js and Redux
- From the authentication, you have to choose “No Authentication” and then click to OK button.
It will take few moments to configure you application and finally project is ready for you with following project structure.
Now everything is ready, to run this project just press F5 or click to “IIS Express”, it will take few minutes to install all dependencies. If you have installed .Net Core SDK 2.0 newly or installed Visual Studio 2017 version 15.3 then it might be you will get following error that says “Unable to connect to web server 'IIS Express'”.
To resolve this issue, you have to do minor change with project configuration. Go to project properties and choose Debug Tab from the right pane.
From the Web Server Setting, you have made changes in App URL, only change PORT [I have changed only one digit] and save the project.
Now project is ready to run and now once again press F5. It will Rebuild solution and run the application. But unfortunately I got another error as following.
To resolve this you have disabled “Chrome script debugging in Visual Studio”. To do that go to Tools menu and choose Options.
From the Debugging option, choose General and find the following option as image shown. You have to disable it.
When you run the project again, it will run and the output will be as following. This is our first Asp.Net Core MVC 2.0 application.
Conclusion
So, today we have learned how to create first Asp.Net Core MVC 2.0 application.
I hope this post will help you. Please put your feedback using comment which helps me to improve myself for next post. If you have any doubts please ask your doubts or query in the comment section and If you like this post, please share it with your friends. Thanks
Lex Li Posted : 7 Years Ago
The default template should not trigger the IIS Express error message though. Have you changed any setting before hitting it? Anyway, changing the settings in Debug tab might force sync the relevant config files, which should resolve the error. More info can be found in https://blog.lextudio.com/what-should-you-check-when-visual-studio-cannot-debug-asp-net-core-projects-4b5db8c5e129