asp.net-core-mvc · from: asp-net-core-mvc It is an unofficial and free asp.net-core-mvc ebook...

22
asp.net-core-mvc #asp.net- core-mvc

Transcript of asp.net-core-mvc · from: asp-net-core-mvc It is an unofficial and free asp.net-core-mvc ebook...

Page 1: asp.net-core-mvc · 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,

asp.net-core-mvc

#asp.net-

core-mvc

Page 2: asp.net-core-mvc · 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,

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

Page 3: asp.net-core-mvc · 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,

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

Page 4: asp.net-core-mvc · 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,

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

Page 5: asp.net-core-mvc · 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,

. , , .

.

.

F5 .

https://riptutorial.com/ko/home 3

Page 7: asp.net-core-mvc · 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,

.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

Page 8: asp.net-core-mvc · 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,

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

Page 10: asp.net-core-mvc · 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,

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

Page 11: asp.net-core-mvc · 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,

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

Page 12: asp.net-core-mvc · 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,

https://riptutorial.com/ko/home 10

Page 13: asp.net-core-mvc · 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,

.

https://riptutorial.com/ko/home 11

Page 15: asp.net-core-mvc · 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,

[ ctrl + P ] .2. " ext install csharp " .3.

C # VS .

https://riptutorial.com/ko/home 13

Page 16: asp.net-core-mvc · 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,

.net .•

https://riptutorial.com/ko/home 14

Page 18: asp.net-core-mvc · 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,

https://riptutorial.com/ko/home 16

Page 19: asp.net-core-mvc · 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,

sdk .

https://riptutorial.com/ko/home 17

Page 20: asp.net-core-mvc · 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,

.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

Page 21: asp.net-core-mvc · 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,

-mvc---

https://riptutorial.com/ko/home 19