dir.by  
Programming, development, testing
.NET Core
Creating a new application ASP.NET Core
  Looked at 8264 times    
 Creating a new application ASP.NET Core 
last updated: 31 October 2025
Step 1. Open Visual Studio
If you do not have Visual Studio installed you need install Visual Studio...
Open Visual Studio 2022
or
Open Visual Studio 2019
Step 2. Create a blank app ASP.NET Core
Click in the menu: FileNewProjectVisual C#ASP.NET Core Web Application
Here we are offered to choose the type of project:
Empty
a blank template with the least functionality for creating applications from scratch
Web API
Web Service Project
Web Application
the project uses requests to process requests Razor Pages
Web Application (Model-View-Controller)
the project uses architecture MVC
Angular
the project is designed to work with Angular 2+
Reat.js
the project uses React.JS
Reat.js and Redux
the project uses React.JS and Redux
Razor Class Library
a project for creating a class library Razor
We can specify the version ASP.NET Core in the drop-down list. In our case, let's leave the default value ASP.NET Core 2.1.

You can also specify the default authentication type in your project and attach the container Docker.

See also "Configure HTTP". if you select this check box the project will run by protocol by default when debugging and testing HTTPS. In this case, selecting or not selecting this check box is irrelevant. In addition, even if we have set this mark, then later through the project properties we can cancel the launch through HTTPS or, conversely, reinstall.

Among these templates, let's choose Empty. Leave all other values to the default and click on the button OK . And Visual Studio 2017 creates a new project:
Step 3. Project Structure ASP.NET Core
Connected Services
connected services from Azure
Dependencies
packages and libraries added to the project (dependencies)
Properties
To run project settings

  json     {rus}файл{/rus} launchSettings.json
{
     "iisSettings": {
          "windowsAuthentication": false,
          "anonymousAuthentication": true,
          "iisExpress": {
               "applicationUrl": "http://localhost:51459",
               "sslPort": 44390
          }
     },
     "profiles": {
          "IIS Express": {
               "commandName": "IISExpress",
               "launchBrowser": true,
               "environmentVariables": {
                    "ASPNETCORE_ENVIRONMENT": "Development"
               }
          },
          "WebApplication1": {
               "commandName": "Project",
               "launchBrowser": true,
               "applicationUrl": "https://localhost:5001;http://localhost:5000",
               "environmentVariables": {
                    "ASPNETCORE_ENVIRONMENT": "Development"
               }
          }
     }
}
wwwroot
To store files: images, javascript, css, etc., which are used by the application. [konec_stroki] The purpose of this folder is to differentiate access (allow and deny access from the client).
Program.cs
The main application file. This file starts the execution of the program. [konec_stroki] The file code configures and starts the web host within which the application is deployed.
Startup.cs
The file contains a class Startup . The class contains logic for processing incoming requests.
Step 4. Run the ASP.NET Core app
Click on the green triangle at the top
Select the checkmark to agree to create a certificate ssl
In the browser we will see the result
"Hello World!"
Text Hello Word! this is the customer's response (variable Response u class Startup)
  C#     File Startup.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;

namespace WebApplication1
{
     public class Startup
     {
          // 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 https://go.microsoft.com/fwlink/?LinkID=398940
          public void ConfigureServices(IServiceCollection services)
          {
          }

          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IHostingEnvironment env)
          {
               if (env.IsDevelopment())
               {
                    app.UseDeveloperExceptionPage();
               }

               app.Run(async (context) =>
               {
                    await context.Response.WriteAsync("Hello World!");
               });
          }
     }
}
Файл Program.cs (оставим без изменений)
  C#     File Program.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace WebApplication1
{
     public class Program
     {
          public static void Main(string[] args)
          {
               CreateWebHostBuilder(args).Build().Run();
          }

          public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
               WebHost.CreateDefaultBuilder(args)
                    .UseStartup<Startup>();
     }
}
 
← Previous topic
Что такое ASP.NET Core ?
 
Next topic →
Создаем новое приложение ASP.NET Core MVC
 
Your feedback ... Comments ...
   
Your Name
Your comment (www links can only be added by a logged-in user)

Экскурсии по Москве Экскурсии по Москве: пешеходные, автобусные и речные прогулки на любой вкус
  Объявления  
  Объявления  
 
Что такое .NET Core ?
Создаем новое консольное приложение .NET Core
ASP.NET Core
Что такое ASP.NET Core ?
Creating a new application ASP.NET Core
ASP.NET Core MVC
Создаем новое приложение ASP.NET Core MVC
Встроенный контейнер IoC в ASP.NET Core

База данных (Entity Framework) в ASP.NET Core MVC
Entity Framework в приложении ASP.NET Core MVC. Используем Code First (пишем c# код, а таблицы в базе данных создаются сами)

Telerik (Kendo UI) в ASP.NET Core MVC
Telerik (Kendo UI) в ASP.NET Core MVC (подключаем Kendo js файлы используя NPM и Webpack)

Аутентификация (login/register/logout) в приложении ASP.NET Core MVC
Аутентификация (authentication) это login/register/logout в приложении ASP.NET Core MVC
Дополнительные темы, вопросы
Install a new version (.NET 9) for Visual Studio 2022 | Error: NETSDK1 The current .NET SDK does not support targeting .NET 9.0. Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 9.0.
Install the new version (.NET 6.0) for Visual Studio 2022. Note! .NET 6.0 is not installed and does not work for Visual Studio 2019
Инсталлируем новую версию (.NET Core 2.2) для Visual Studio 2019
Выбор между ASP.NET Core и ASP.NET ?
Перенос кода в .NET Core из .NET Framework
Error "unable to connect to web server "iis express" | ASP.NET Core | Visual Studio 2017
Error "This site can't be reached" when run ASP.NET Core application | Solution: Recreate the Self-Signed HTTPS Certificate for localhost in IIS Express
WWW сайты для изучения
Сайты для изучения ASP.NET Core

  Ваши вопросы присылайте по почте: info@dir.by  
Яндекс.Метрика