In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what is the development of asp.net core". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. ASP.NET Core introduction
In the early days, Microsoft developed asp applications to replace CGI scripts. ASP full Active Server Page, which means the active server web page. ASP is a combination of HTML+ server code with the suffix .asp.
In 2001, Microsoft announced that it would migrate asp to .NET Framework, creating a new scripting language called asp.net. The first version, named ASP.NET 1.0, was released in 2002, attached to the .NET Framework 1.0. ASP.NET is not only asp +, but also asp +. Net. Combined with. Net, asp.net is more powerful.
One year before 2008, asp.net mvc was launched. Since then, asp.net has been divided into two technologies: asp.net webform (that is, the original asp.net) and asp.net mvc. MVC greatly reduces a large number of server scripts in the foreground page, while MVC is closer to HTML language, so that program development engineers and front-end can better cooperate.
In 2016, Microsoft extracted the. NET Core version of the .NET Framework to implement its cross-platform strategy, and released version 1.0 in the same year. At the same time, the asp.net core RTM version was released, and the official version was released in 2017.
From then on,. Net core advanced by leaps and bounds with its buddies EF Core and ASP.NET Core, and then developed into the status quo.
Of course, a large number of plots are omitted from the above, and interested partners can consult the relevant materials themselves. Here will not do too much introduction, because the length is too long, and will deviate from the main line.
1.1 Why ASP.NET Core
So why did we choose ASP.NET Core? At present, there are many industry systems and related systems in the market that use ASP.NET Webform, and the market share is still not small. But we have to consider one thing, that is, first mover advantage and corner overtaking.
The situation now is that the old technology market is full of people, and the new technology market is still empty (of course, at the time of this article-2020-5-29---asp.net core is not new). If you want to enter a technology, then the most suitable thing is to learn the latest.
Furthermore, ASP.NET Core supports cross-platform support. At first,. Net did not support cross-platform, and then Mono made efforts to get. Net to support cross-platform. Later, Microsoft put forward the cross-platform strategy and the Internet of things strategy, and then put forward the formal cross-platform implementation.
Well, I think there's a good reason for this.
1.2Why MVC?
MVC is the abbreviation of Model-View-Controller, meaning model-view-controller. Its communication flow is as follows:
User access interface (View), submit requests (including access requests)
The interface forwards the user's request to the controller (Controller) and encapsulates it to a certain extent
After the processing and completion of the controller (Controller), it is returned to View in the form of Model
View parses the returned Model, and then draws the interface to show the user
MVC reduces the coupling between the page and the controller, which in short greatly reduces the number of server scripts on the page. In addition, page reuse is enhanced. ASP.NET Core MVC is further optimized for this convenience and reduces tags that do not conform to the HTML format.
Of course, MVC has more benefits. The most important thing, however, is that MVC can bring you one step closer to those bosses (meaning you can get a job).
2. Getting started with ASP.NET Core
In the last section, I talked a lot of nonsense, which may have dispelled the interest of many people. Haha, it was a joke. Let's officially start to try ASP.NET Core.
Create a solution first:
Dotnet new sln-name AspDemo
Create a MVC project and add it to the solution
Dotnet new mvc-name MvcWeb
Dotnet sln add MvcWeb
At this point, if nothing happens, you can see the following directory structure under the AspDemo directory:
├── AspCoreDemo.sln
└── MvcWeb
├── appsettings.Development.json
├── appsettings.json
├── Controllers
│ └── HomeController.cs
├── Models
│ └── ErrorViewModel.cs
├── MvcWeb.csproj
├── obj
│ ├── MvcWeb.csproj.nuget.dgspec.json
│ ├── MvcWeb.csproj.nuget.g.props
│ ├── MvcWeb.csproj.nuget.g.targets
│ ├── project.assets.json
│ └── project.nuget.cache
├── Program.cs
├── Properties
│ └── launchSettings.json
├── Startup.cs
├── Views
│ ├── Home
│ │ ├── Index.cshtml
│ │ └── Privacy.cshtml
│ ├── Shared
│ │ ├── Error.cshtml
│ │ ├── _ Layout.cshtml
│ │ └── _ ValidationScriptsPartial.cshtml
│ ├── _ ViewImports.cshtml
│ └── _ ViewStart.cshtml
└── wwwroot
├── css
│ └── site.css
├── favicon.ico
├── js
│ └── site.js
└── lib
├── bootstrap
│ ├── dist
│ │ ├── css
│ ├── bootstrap.css
│ ├── bootstrap.css.map
│ ├── bootstrap-grid.css
│ ├── bootstrap-grid.css.map
│ ├── bootstrap-grid.min.css
│ ├── bootstrap-grid.min.css.map
│ ├── bootstrap.min.css
│ ├── bootstrap.min.css.map
│ ├── bootstrap-reboot.css
│ ├── bootstrap-reboot.css.map
│ ├── bootstrap-reboot.min.css
│ └── bootstrap-reboot.min.css.map
│ │ └── js
│ │ ├── bootstrap.bundle.js
│ │ ├── bootstrap.bundle.js.map
│ │ ├── bootstrap.bundle.min.js
│ │ ├── bootstrap.bundle.min.js.map
│ │ ├── bootstrap.js
│ │ ├── bootstrap.js.map
│ │ ├── bootstrap.min.js
│ │ └── bootstrap.min.js.map
│ └── LICENSE
├── jquery
│ ├── dist
│ │ ├── jquery.js
│ │ ├── jquery.min.js
│ │ └── jquery.min.map
│ └── LICENSE.txt
├── jquery-validation
│ ├── dist
│ │ ├── additional-methods.js
│ │ ├── additional-methods.min.js
│ │ ├── jquery.validate.js
│ │ └── jquery.validate.min.js
│ └── LICENSE.md
└── jquery-validation-unobtrusive
├── jquery.validate.unobtrusive.js
├── jquery.validate.unobtrusive.min.js
└── LICENSE.txt
A brief introduction to several directories in the MvcWeb project:
The controller is stored in the Controllers, which is responsible for processing the data returned by the view.
Model layer code is stored in Models, directory name is not required, and it is not necessary to be here.
Views stores the view path, which is a fixed name
Wwwroot is used to store some js scripts and css style sheets
The obj directory is a compiled directory, so you don't have to worry too much about it for the time being.
So, let's run this project to see how it works:
Cd MvcWeb
Dotnet run
# or
Dotnet run-porject MvcWeb
If the following appears, the project has been started and completed:
Then enter in the browser:
Http://localhost:5000
Then you can see the following:
At present, it is an empty project, do not worry, in the following articles in this series, we will continue to enrich this project to make its content richer and more in line with our needs.
3. Program.cs
Do you think the name is familiar? Yes, we used the console program every time we demonstrated before, and there is a Program.cs file with a Main method in it. We know that the Main method is the entrance to a program. Previous Asp.net projects did not have this approach because previous projects were based on IIS. On the other hand, asp.net core is detached from IIS so that it can run directly, so there is an entry method.
The code should be as follows:
Public class Program
{
Public static void Main (string [] args)
{
CreateHostBuilder (args). Build (). Run ()
}
Public static IHostBuilder CreateHostBuilder (string [] args) = >
Host.CreateDefaultBuilder (args)
.ConfigureWebHostDefaults (webBuilder = >
{
WebBuilder.UseStartup ()
});
} 3.1 modify Port
When we use it, the port is often occupied, so it is necessary for us to set the port. The setting method is as follows:
WebBuilder.UseUrls ("http://*:5006");"
Then restart the project and you can see that the port has changed.
4. Setup.cs
This class is used to configure the request pipeline for services and applications. This is an agreed name. The initial version of the class file should look like this:
Public class Startup
{
Public Startup (IConfiguration configuration)
{
Configuration = configuration
}
Public IConfiguration Configuration {get;}
/ / This method gets called by the runtime. Use this method to add services to the container.
Public void ConfigureServices (IServiceCollection services)
{
Services.AddControllersWithViews ()
}
/ / This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Public void Configure (IApplicationBuilder app, IWebHostEnvironment env)
{
If (env.IsDevelopment ())
{
App.UseDeveloperExceptionPage ()
}
Else
{
App.UseExceptionHandler ("/ Home/Error")
/ / The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
App.UseHsts ()
}
App.UseHttpsRedirection ()
App.UseStaticFiles ()
App.UseRouting ()
App.UseAuthorization ()
App.UseEndpoints (endpoints = >
{
Endpoints.MapControllerRoute (
Name: "default"
Pattern: "{controller=Home} / {action=Index} / {id?}")
});
}
} this is the end of the content of "what is the Development of asp.net core"? thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.