search
HomeBackend DevelopmentC#.Net TutorialASP.NET Core project structure tutorial (4)_Practical tips
ASP.NET Core project structure tutorial (4)_Practical tipsJun 28, 2017 pm 02:10 PM
asp.netcoreTutorial

This article mainly introduces the ASP.NET Core project structure to everyone in detail, which has certain reference value. Interested friends can refer to

in this chapter , we will discuss how ASP.NET Core projects are organized on the file system and how different files and directories work together.

Let's open the FirstAppDemo project created in the previous chapter.

In the Solution Explorer window, right-click the solution node and select "Open Folder in File Explorer".

You will see two files in its root directory: FirstAppDemo.sln and global.json.

The FirstAppDemo.sln file is a solution file. Visual Studio has used the sln extension by default for many years. If you want to open the application in Visual Studio, you can double-click this file.

There is also a global.json file. Let's open this file in Visual Studio.

In the global.json file, the project settings are very important. This project setting tells ASP.NET where to look for your source code and which folders contain your project source code.

Generally, a newly created project contains two important folders: the "source" folder containing the source code and a "test" folder. Unless your project and source code are in both folders, the project will fail to compile. If necessary, you can change these settings to suit your needs.

There is no test folder in our current project. In the test folder, you can store your unit test projects. Let's double click on the "src" folder.

You can see the FirstAppDemo web application project now, double click on the folder.

These are the source code files for the application, you can also see this folder structure in the Solution Explorer window.

If you add a new file to the project folder, the file will automatically be added to the project. If you delete a file, the file will also be deleted from the project. Everything stays in sync between the project and the file system, which is a bit different from previous Asp.NET versions.

ASP.NET Core will also automatically compile your application when files change or new files are added.

Case

Let us look at a simple example, open the Startup.cs file in Notepad:

The following line The code is used to respond to every HTTP request made to the application, here it only responds "Hello World!"

Let's modify the string in the screenshot above to "Hello World! This ASP.NET Core Application", as shown below:


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;
using Microsoft.Extensions.Logging; 
namespace FirstAppDemo {
 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 http://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, ILoggerFactory loggerFactory) { 
   loggerFactory.AddConsole(); 
   
   if (env.IsDevelopment()){ 
   app.UseDeveloperExceptionPage(); 
   } 
   app.Run(async (context) => { 
   await context.Response.WriteAsync(
    "Hello World! This ASP.NET Core Application");
   });
  } 
 } 
}


In textEditor Press Ctrl+S to save this file, then return to the web browser and refresh the application.

You can now see your changes reflected in the browser.

  • This is because ASP.NET monitors the file system and automatically compiles the application when files change. You don't need to explicitly recompile the app in Visual Studio.

  • Actually, you can use a different editor, such as Visual Studio Code, etc.

  • All you need to do when using Visual Studio is start the web server by running the debugger. You can also press Ctrl + F5 to edit the file, save the file, and refresh the browser to see the changes.

  • This is a great flow for building web applications using C#.

The above is the entire content of this article. I hope it will be helpful to everyone’s study. I also hope that everyone will support Script House.

The above is the detailed content of ASP.NET Core project structure tutorial (4)_Practical tips. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
如何在 Windows 11 中启用 Core Isolation 的内存完整性功能如何在 Windows 11 中启用 Core Isolation 的内存完整性功能May 10, 2023 pm 11:49 PM

Microsoft的Windows112022Update(22H2)默认启用CoreIsolation的内存完整性保护。但是,如果您运行的是旧版本的操作系统,例如Windows112022Update(22H1),则需要手动打开此功能。在Windows11中开启CoreIsolation的内存完整性功能对于不了解核心隔离的用户,这是一个安全过程,旨在通过将Windows上的基本核心活动隔离在内存中来保护它们免受恶意程序的侵害。该进程与内存完整性功能相结合,可确保

电脑core是什么意思电脑core是什么意思Sep 05, 2022 am 11:24 AM

电脑中core有两种意思:1、核心,也即内核,是CPU最重要的组成部分,CPU所有的计算、接受存储命令、处理数据都由核心执行;2、酷睿,core是英特尔的处理器名称,酷睿是英特尔公司继奔腾处理器之后推出的处理器品牌,目前已经发布了十二代酷睿处理器。

3分钟快速使用ChatGPT教程,用它帮我写简历,太牛了3分钟快速使用ChatGPT教程,用它帮我写简历,太牛了Apr 11, 2023 pm 07:40 PM

已经火了很久了,身边的同事也用它来进行一些调研,资源检索,工作汇报等方面都有很大的的效率提升。很多人问ChatGPT会不会取代程序员?我的回答是:不会!ChatGPT并不是我们的敌人,相反的是,它是我们的好帮手。未来人和人的竞争,可能就会从原先的我懂得更多,我实操经验更丰富,变成了我比你更会用工具,我比你更懂得提问,我比你更会发挥机器人的最大特性,所以,为了不掉队,你还不准备体验下ChatGPT吗?快速体验面试官经常会问你的项目有啥重难点?很多人不会回答,直接看看ChatGPT怎么说,真的太牛了

2023年最流行的5个php开发框架视频教程推荐2023年最流行的5个php开发框架视频教程推荐May 08, 2017 pm 04:26 PM

如果想快速进行php web开发,选择一个好用的php开发框架至关重要,一个好的php开发框架可以让开发工作变得更加快捷、安全和有效。那2023年最流行的php开发框架有哪些呢?这些php开发框架排名如何?

u盘怎么重装win11系统的步骤教程u盘怎么重装win11系统的步骤教程Jul 08, 2023 pm 09:33 PM

微软近日透露了将推出win11系统,很多用户都在期待新系统呢。网上已经有泄露关于win11的镜像安装系统。大家不知道如何安装的话,可以使用U盘来进行安装。小编现在就给大家带来了win11的U盘安装教程。1、首先准备一个8G以上大小的u盘,将它制作成系统盘。2、接着下载win11系统镜像文件,将它放入u盘中,大家可以直接点击右侧的链接进行下载。3、下载完成后装载该iso文件。4、装载完成之后会进入新的文件夹,在其中找到并运行win11的安装程序。5、在列表中选择“win11”然后点击“下一步”。6

如何修复 Windows 11 / 10 中的处理器热跳闸错误 [修复]如何修复 Windows 11 / 10 中的处理器热跳闸错误 [修复]Apr 17, 2023 am 08:13 AM

大多数设备(例如笔记本电脑和台式机)长期被年轻游戏玩家和编码人员频繁使用。由于应用程序过载,系统有时会挂起。这使用户被迫关闭他们的系统。这主要发生在安装和玩重度游戏的玩家身上。当系统在强制关闭后尝试启动时,它会在黑屏上抛出一个错误,如下所示:以下是在此引导期间检测到的警告。这些可以在事件日志页面的设置中查看。警告:处理器热跳闸。按任意键继续。..当台式机或笔记本电脑的处理器温度超过其阈值温度时,总是会抛出这些类型的警告消息。下面列出了在Windows系统上发生这种情况的原因。许多繁重的应用程序在

PHP基础教程:从入门到精通PHP基础教程:从入门到精通Jun 18, 2023 am 09:43 AM

PHP是一种广泛使用的开源服务器端脚本语言,它可以处理Web开发中所有的任务。PHP在网页开发中的应用广泛,尤其是在动态数据处理上表现优异,因此被众多开发者喜爱和使用。在本篇文章中,我们将一步步地讲解PHP基础知识,帮助初学者从入门到精通。一、基本语法PHP是一种解释性语言,其代码类似于HTML、CSS和JavaScript。每个PHP语句都以分号;结束,注

老电脑系统xp升级win7教程步骤老电脑系统xp升级win7教程步骤Jul 07, 2023 pm 10:21 PM

xp系统曾经是使用最多的系统,不过随着硬件的不断升级,xp系统已经不能发挥硬件的性能,所以很多朋友就想升级win7系统,下面就和大家分享一下老电脑升级win7系统的方法吧。1、在小白一键重装系统官网中下载小白三步装机版软件并打开,软件会自动帮助我们匹配合适的系统,然后点击立即重装。2、接下来软件就会帮助我们直接下载系统镜像,只需要耐心等候即可。3、下载完成后软件会帮助我们直接进行在线重装Windows系统,请根据提示操作。4、安装完成后会提示我们重启,选择立即重启。5、重启后在PE菜单中选择Xi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),