asp.net-core-mvc · from: asp-net-core-mvc It is an unofficial and free asp.net-core-mvc ebook...
Transcript of asp.net-core-mvc · from: asp-net-core-mvc It is an unofficial and free asp.net-core-mvc ebook...
asp.net-core-mvc
#asp.net-
core-mvc
1
1: asp.net-core-mvc 2
2
Examples 2
2
Visual Studio 2
ASP.NET MVC . 2
MVC 4
5
6
6
2: 8
8
Examples 8
8
8
3: . MVC .net mvc . 9
9
9
Examples 9
1 - 9
2 - .Net C # . 12
3 - MVC . 18
4 - . 18
20
You can share this PDF with anyone you feel could benefit from it, downloaded the latest version from: asp-net-core-mvc
It is an unofficial and free asp.net-core-mvc ebook created for educational purposes. All the content is extracted from Stack Overflow Documentation, which is written by many hardworking individuals at Stack Overflow. It is neither affiliated with Stack Overflow nor official asp.net-core-mvc.
The content is released under Creative Commons BY-SA, and the list of contributors to each chapter are provided in the credits section at the end of this book. Images may be copyright of their respective owners unless otherwise specified. All trademarks and registered trademarks are the property of their respective company owners.
Use the content presented in this book at your own risk; it is not guaranteed to be correct nor accurate, please send your feedback and corrections to [email protected]
https://riptutorial.com/ko/home 1
1: asp.net-core-mvc asp.net-core-mvc , .
asp.net-core-mvc . asp.net-core-mvc .
Examples
Visual Studio
Visual Studio Visual Studio Community Edition . .
ASP.NET MVC .
Visual Studio .1. > .2. .3. .4. : .NET Framework .5. .6. .7.
.
https://riptutorial.com/ko/home 2
. , , .
.
.
F5 .
https://riptutorial.com/ko/home 3
.
: asp.net asp.net .
MVC
mvc .
"Microsoft.AspNetCore.Mvc": "1.0.1"
"dependencies" project.json .
Startup MVC .
public void ConfigureServices(IServiceCollection services) { ... services.AddMvc(); }
Service.AddMvc services.AddMvc() services.AddMvcCore() . asp.net core services.AddMvc() . MVC services.AddMvcCore() . AddMvcCore .
public void ConfigureServices(IServiceCollection services) { services .AddMvcCore()
https://riptutorial.com/ko/home 4
.AddAuthorization() .AddJsonFormatters(j => j.Formatting = Formatting.Indented); }
mvc :
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { ... app.UseMvc(); }
:
app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); });
. ( ) . .
, config .
public interface ISomeDependency { async Task<IEnumerable<string>> GetItemsAsync(string key); } public class SomeDependency : ISomeDependency { public SomeDependency(string connectionString) { ... } ... }
.
public class SomeController : Controller { private reanonly ISomeDependency dependency; public SomeController(ISomeDependency dependency) { ... this.dependency = dependency; } ... public async Task<IEnumerable<string>> Get(string key) =>
https://riptutorial.com/ko/home 5
await dependency.GetItemsAsync(key); }
services.AddTransient Startup.ConfigureServices .
public class Startup { public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder(). .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) ... Configuration = builder.Build(); } public IConfigurationRoot Configuration { get; } public void ConfigureServices(IServiceCollection services) { ... services.AddTransient(serviceProvider => new MyDependency(Configuration["Data:ConnectionString"])); } ... }
Data:ConnectionString appsettings.json .
{ ... }, "Data": { "ConnectionString": "some connection string" } }
AddTransient AddSingleton AddScoped . HTTP .
@ Github
RC1 * 1.0.0-rc1 2015-11-01
RC2 * 1.0.0-rc2 2016-05-16
1.0.0 1.0.0 2016-06-27
1.0.1 1.0.1 2016-09-13
1.0.1 1.0.1 2016-09-13
1.1 1.1.0 Q4 2016 / Q1 2017
https://riptutorial.com/ko/home 6
1.2 1.2.0 2017 1 / 2 2017
* (Q1, Q2, Q3, Q4) .
asp.net-core-mvc : https://riptutorial.com/ko/asp-net-core-mvc/topic/2174/asp-net-core-mvc-
https://riptutorial.com/ko/home 7
2: ASP.NET MVC Views . .
Examples
IViewLocationExpander . ExpandViewLocations IEnumerable<string> .
public class MyViewLocationExpander : IViewLocationExpander { public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations) { yield return "/CustomViewFolder/{1}/{0}.cshtml"; yield return "/SharedFolder/{0}.cshtml"; } public void PopulateValues(ViewLocationExpanderContext context) { } }
Razor View Engine Expander . Startup ConfigureServices .
public void ConfigureServices(IServiceCollection services) { services.Configure<RazorViewEngineOptions>(options => { options.ViewLocationExpanders.Add(new MyViewLocationExpander()); }); }
: https://riptutorial.com/ko/asp-net-core-mvc/topic/8669/--
https://riptutorial.com/ko/home 8
3: . MVC .net mvc .Visual Studio Asp.Net . MVC .
...
1 - Visual Studio .
2 - .Net C # .
3 - MVC .
4 - .
Visual Studio .net mvc .
( ).•.•
Examples
1 -
Visual Studio . Visual studio code . [mac | windows | linux] .•
https://riptutorial.com/ko/home 9
.
2 - .Net C # .
Visual Studio .net C # .
C # . URL : C # .net •
Visual Studio .1.
https://riptutorial.com/ko/home 12
[ ctrl + P ] .2. " ext install csharp " .3.
C # VS .
https://riptutorial.com/ko/home 13
.net core SDK . Windows => CommandLine .
https://riptutorial.com/ko/home 15
https://riptutorial.com/ko/home 16
sdk .
https://riptutorial.com/ko/home 17
.Net SDK .
3 - MVC .
Windows .•
" dotnet new -t web " . mvc .•
mvc .•
" dotnet restore " . project.json .•
VScode .•
VS mvc .
mvc [Model-View-Controller]
4 - .
VScode .
.
.
. .Net () .
.
. .
.
" F12 " .
.
jquery .
[VS Ctrl + Shift + f CSS .]
cdn .
.
.
.
. MVC .net mvc . : https://riptutorial.com/ko/asp-net-core-mvc/topic/8997/------mvc-------net-
https://riptutorial.com/ko/home 18
-mvc---
https://riptutorial.com/ko/home 19
S. No
Contributors
1 asp.net-core-mvc Community, Ole K, Rafael Marques, Set, stop-cran, tmg, Zach Becknell
2 glacasa
3. MVC .net mvc .
Andi AR
https://riptutorial.com/ko/home 20