Kamis, 11 Mei 2017

web design software visual studio

web design software visual studio
web design software visual studio

hello, everyone. >> hello.>> hello, ignite. great, welcome. we're going to bedoing an exploration of web developmentusing asp.net core 1.0. my name is daniel roth, i'm a seniorprogram manager on the asp.net team. and this is going to bean introduction to asp.net core 1.0. if you want to go deeper, we dohave another talk later this week. it will be a deep diveinto asp.net core 1.0.

so, i encourage you toattend that as well. but for this talk, we're going to be talking allabout what is asp.net core, what is it for, why do we buildit and what can it do for you. asp.net core is a completely newopen-source and cross-platform framework for building cloud-basedweb applications using .net. and by new, we really do mean new. this is not system.web.dll. it is a completely fresh take ondoing web development with .net.

and as such, we actually dida rename a little while ago. we used to call thisframework asp.net5. and the reason why weoriginally called is that, is because while it is new,it should also feel really familiar. again, if you know .net, you know c #, you know asp.net todaylike you're doing mbc development. asp.net course should feelsuper familiar to you. all those skills will carry forward,but it is a completerewrite of the stack,

completely new request pipeline,completely new hosting model. and so awhile back we actuallydecided that we should really give this thing a new nameand it is really a 1.0 release of a frame work so we renamed itfrom asp.net 5 to asp.net core. you may still see asp.net 5kicking around on the internet. it should really becalled asp.net core 1.0. and it is 1.0 and i'm super excitedbecause earlier this summer, we shipped the first stablerelease of asp.net core for all of you to use itis production ready.

it is stable. we have customers that are using itin their production apps on windows, developing on their macs,running it on linux, running it in docker containers. it's been quite a journey. i think we've been working onasp.net core now for probably over three years, at least that's howlong i've been working on it. there probably were some peopleworking on it a little bit earlier than that even.

so it's been quite a journey, andit's great that now we have it, we can give it to you, and you can have it in your hands toactually build your applications. why did we build asp.net core? well there's a bunch of reasons. the first one is that wewanted something that was completely modular. everything in asp.net coreis just a nougat package. and if you want it in your app,you pull it into your app.

if you don't want it, don't addthe package and it's not there. the .net framework,as it exists today, is great. it is very mature,very powerful framework. has a lot of features in it, butit's very monolithic in nature. it's basically all or nothing. you get all of the .net framework oryou get none of the .net framework. if you're running a serverapplication, well wpf is still there even though you'reprobably not using any of it and that has impact in terms of itssurface area on your application.

with asp.net core youdon't have that issue. you can have,it's literally a pay for play model. if you want it, put it in your app. if you don't want it,it's not there. we wanted to have a muchfaster development cycle for our web framework, andthat really means two things to me. the first thing it means isthat we can get features to you a lot faster. we just ship on we actuallyshipped our first patch update to

asp.net core just a month ortwo ago, the 1.0.1 patch release. and we expect to continue to dothat about every two months. we wanna get new bits into yourhands, at least that fast. the .net framework isa windows component. so it moves at the pace of windows. windows is moving faster and faster. every year they keepgetting more and more features to usquicker which is great. but it still has to move atthat pace that windows can go.

we wanted something that we canget features to you faster. also the framework was designedwith your productivity in mind. you have a much faster innerloop development cycle where you can quickly change your code. see it in the browser much fasterby just hitting f5 and refreshing. those type of user experiences, wewanted to make you more productive. asp.net core was designedwith the cloud in mind. this means that we have beenable to optimize the run time, we've been able to optimizethe api's that we build

to think about what it means tobuild a cloud based application. we have a new configuration model, for example, in asp.net corethat is environment based. so that you can have configurationsettings that are relevant when you're in development and then othersettings that are relevant when you're staging andthen in production. and your app can just pick up thosesetting from it's environment. the .net framework runsgreat in the cloud today but with asp.net core we really hadan opportunity to think about front

what does it mean to builda .net cloud application. we wanted you to have choice whenbuilding your asp.net core app. choice in terms of whattools you want to use and how do you want todo your development. you should be able to be productive,building asp.net core apps with just a command prompt andyour favorite text editor. and if that happens to be vim oremacs or whatever, that's fine. you can be productiveusing asp.net core. we, of course,also have a great red carpet tooling

experience in visual studiowith great editors and in telescience anddebuggers and all that. but if you want to just usea command prompt and text editor, or your development tool of choice,that's fine, no vs required. the whole stack is open source andaccepting contributions. we've had a lot of greatcontributions from the community. everything from bugfixes to new features to fantastic performanceimprovements. the community's been great.

we encourage you if you'd like toparticipate in the development of this framework, by all meansjoin on github, file issues, give us your feedback,send us your poll requests. lastly, second to lastly, we wantedthis stack to be cross platform, and this is really courtesy ofour friends on the .net team who gave us .net core. .netcore is the new open source andcross-platform flavor of .net. and it runs on windows, mac, andlinux, asp.net core, runs happily on top of .net core that allows us torun in all of those environments.

lastly, we wantedsomething that was fast. with asp.net core,we had an opportunity to really look again at the request pipeline,really optimize and really get just phenomenalthroughput numbers in terms of requests per second that youcan get out of the core pipeline. to get started with asp.net core, the first thing you're gonna wannado is you need to go get .net core. so you should go to dot.net. yes, that's how we say it dot.net.

and that's where you can geteither the dot.net core stk that you can use on whatever platformyou happen to be developing on. whether it's a windows machine ora mac. or if you happen to be on windowsand you like using visual studio, you should also get the .net coretooling for visual studio and that will give you templates anddebugging experience within vs. our docs are at docs.asp.net. and of course our source code isavailable at github in the asp.net org at github.com/asp.net.

we also have a lot of really greatsamples there as well that you can look at. this is what asp.net corelooks like, in a nutshell. on your left hand side,at the bottom, you see we have the existing.net framework. this is a windows component. there's lots of mature andgreat functionality in it but it only runs on windows. on top of that, we havesystem.web.dll or asp.net 4.6 and

a variety of application frameworksthat we've built over the years on top of system.web like web forms, mvc, web apis, signal r,identity and so forth. on your right hand side you can seethe bottom is the new .net core. this is our cross platformopen source of .net and it runs on windows, mac, and linux. that's what we've builtasp.net core on top of, but you'll notice that it actually, sort of spans a little bit over ontothe .net framework side as well.

why is that? this is because the asp.net core isreally just a bunch of libraries. it's a bunch of nuget packages. we have cross-compiled thesepackages, these libraries, so that they can run on either .netcore or on the full .net framework. that's important .net core is core. it's api surface area in order forit to be factored as a set of packages like the whole stackis without a core isasp.net core the apis had to be shall we say,modernized.

the had to be decoupled a littlebit which means that it's not binary compatible with the existingbinaries that you've built for the .net framework. so you do generally have to compilespecifically for .net core. the api surface area is also somehowlimited compared to the .net framework. but that is rapidly changing. the .net team is very rapidly built flashing out the set of apisthat are available on .net core.

and we expect to have actuallya really great compatibility experience going inthe months ahead. but you can run your asp.net coreapp on either .net core, which will give youcross platform or you can write it on the full desktopframework on the .net framework. and that gives you better compatibility in termsof your existing binaries. so if you have either third partydependencies or your own assets that really only run on the .netframework today, that's fine.

you can still use asp.net core andget that binary compatibility, albeit on windows. and then on top of asp.net core, wehave our new web application model, asp.net core mvc. and what do you getwith asp.net core? so there's a completelynew hosting model, and it's completely coupled from is,you can host your asp.net core apps, any type of asp.net core app. whether it's a service or your webui, in whatever process you'd like,

they're basicallyjust a console app. we have a new server thatcomes with asp.net core, it's a managed serverthat we call kestrel. kestrel is a small,fast bird, if you don't know. kestrel is actually built on topof the same native core that is used by node.js, libuv, and it'svery fast and very light weight. the hosting model has a new modelfor defining the start up logic for your application, sothere's a new start up model. we have a completely new hprequest handling pipeline

that's made up of componentsthat we call middleware. and middleware are completelyasynchronous, very light weight. and we provide you a bunch ofmiddleware out of the box. we have middleware for routing,authentication, static files, diagnostics, error handling,cors, session, localization. you can build your own middlewareand plug them into the stack. and we're also, of course,continuing to build new ones. we have middleware thatare in the pipeline. we have url rewritemiddleware that's coming.

response, caching, middleware,that's coming as well. dependency injection isbuilt into asp.net core. and this is great, cuz thismeans that it's really easy for you to express your dependenciesin your middleware, or your controllers, and then be ableto easily test those components by just mocking out those dependencies. asp.net core comes witha built in ioc container. it's a very simple container,just meant to boot strap the system. if you're not superpassionate about di,

then that container probablywill suit your needs. if you have a particularcontainer that you love and you want to use it instead,that's fine. you can easily replace the builtin ioc container with your own, whether that's autofac orstructure map or whatever. which as i said earlier isenvironment aware, so that you can have configuration settings that arepicked up from current environment. there's a logging framework that'sbuilt throughout the system so it's really easy to get diagnosticsdata throughout the stack.

and then lastly, we have our application frameworks,asp.net core mvc. we have support for identity, doinguser management and user profiles. signalr is available in preview, but it is being rapidly worked on rightnow and should be coming soon. a word aboutthe application frameworks, if you look at asp.net today,we have a sort of a siloed model for how you build appswith asp.net today. there's a variety of differentapplication frameworks that you can

choose from when your buildingon top of system.web, and they all serve a,they work great for specific needs thatthey were built for. but unfortunately,they're siloed and they don't share a lot offunctionality that you might expect. like for example, web pages and mvc, they both share razoras their view syntax. but that's all they really share, like the html helperare completely different.

mvc and web api, they share a lotof concepts, they both have controllers and actions, andfilters, and model binding, and di abstractions, butthey actually share no code at all. and the reasons for that,when we built web api, we wanted web api to be de-coupledfrom is, and system.dll, so that you could host itin your own process. mvc was already tied tosystem web and is, so web api couldn't takedependency on mvc. but this causes confusion,people will ask us,

like i've wrote a filter,why isn't it working in my web api? i accidentally usedthe traction from mvc. and it also creates duplication forus, like when we want to ship features to you, we end up oftenhaving to implement them twice. like, once for mvc andonce for web api. so we'd like to fix this withasp.net core, and so we're creating a single, unified web framework fordoing both web ui and web apis. and what does that look like? so asp.net core mvc gives youone set of concepts, can do ui,

can do web apis, can do contentnegotiation, can do razor. it supports .net core of course, cuzit's built on top of asp.net core. you can run it in iis,you can run it self-hosted. it deeply integrates withthe di system in asp.net core, so you can inject dependencies intoyour controllers, into your filters, even into your views. and then, on top of all that, we've evenadded new features to the stack. one of my favorites is tag helpers,

which is a really simple wayto associate some server side logic with the tag that you'rerendering in your view. then we'll takea look at that today. okay. so that's your brief 15-minuteintroduction to what asp.net core is all about. but of course, it's much easierjust to look at the code. so let's look at the code. all right.

so let's get started withasp.net core together. and you should do this. if you haven't done this yet,it literally will take you five minutes to get started withyour first .net core app and your first asp.net core app. what you wanna do is like i said,you're gonna wanna go to .net, okay? and that's where you'regonna get .net core. you're gonna wanna pick .net core,and then depending on which os you're on, windows, mac,linux, doesn't matter.

if you wanna do it in docker,that's fine, too. you're gonna wanna installeither the .net core sdk, or if you're on windows, you can get the .net core toolingfor visual studio, all right? so you can install that. i've already done that. and so if i go to the commandline and then type, dotnet, this is the executor and also the nativehost that comes with dot net core. and i see yeah,i've got .net core in my machine. okay?

so that looks good. let's create our first.net core application. i'm going to create a new directory,let's create, hello world. we're just gonna do,hello world really quick. i'm gonna change this directory, soto create my first .net core app. i'm just gonna do, dotnet new, and that will create me the basicsof an app right out of the box. okay, so it create something,click create new directory, i've got a couple files.

now, i'm gonna use my favorite texteditor for dealing with .net core, i'm not gonna use full vs yet. but i am gonna use visualstudio code, which is a simple, light weight text editor. and has some nice features,when working with .net core apps. it's cross-platform, so if you'redoing these same steps on a mac, that's fine, this will stillwork for you, as well. i'll also show you all of thecommand line versions of everything that i do, in visual studio code.

let's start vs code. and take a look at what we've got. okay, so we've got,let's make it a little bigger. program cs, okay,that looks like your normal, hello world console app. i got just a couple ofnotifications from vs code here. what are these? so the first one here says thatthere are unresolved dependencies for my project.json file.

please execute the restorecommand to continue. and what is that? well, you notice i'm getting allthese red squigglies as well, i can't find some of the types. everything, remember, in asp.netcore is a package, a nuget package. if i look at this project.json file, this is the file that,this is just a simple chunk of json that expresses all the packagesthat my app depends on. now this is hello world, soit depends on almost nothing.

the only dependency it really hasis the .net core app package. but whenever you have a dependencyin a .net core world, you need to restore thosedependencies onto your machine. you need to pull down the packagesand make them available to your app. so let's do that. i could do that righthere from vs code, but i wanna show you how you do itfrom the command line first, so i'm just gonna do, dotnet restore. and that's gonna bring, go and

grab all of the dependencies thatmy application needs to run. there, it's done. by the way,a trick if you ever, well, before i show you the trick, noticethat after i run dotnet restore, i've got a new file in my project. this is project.lock.json file. what is this thing? this is a serialized representationof the entire package graph, the dependency graphthat this app needs.

so it's got all the dependencies forall the system.star packages. and if you wanna putyourself to sleep at night, this makes for a great read, just goahead and browse through that guy. so yeah, if you are curious wherethe packages are coming from, when you run a dotnet restore, one trick is to do dotnetrestore -v information. and this will just doa normal restore, but it will also tell youwhich nuget.config files are being used to decide which feedsit should query for the packages.

most of your packages are gonna comefrom the official nuget.org feed. when you install the packages using, when you installthe visual studio tooling, it will give you like a localversion of those packages as well. and then i have my ownlittle feed that i set up so that's how you can find out whereyour packages are coming from. now, when you restored them,where did they go to? like, where are theyon your machine? they're all put into your userprofile when you're doing .net

core development. so, if i go to my user profile,there's a .nuget folder. and there's your packages. so, you can see i have lots ofpackage goodness inside of on my laptop. okay, that's where allof your packages went. okay, so we've done a restore. and now i want to run this app. how do i do that?

so to run your app,you can just do, dotnet run. and that actually does two things. it'll first build your application. it'll produce the binary. it actually is usingroslyn under the covers. and then it will justuse the .net executor to execute the entry point of your app. so .net run, you should see thosetwo steps, look it's compiling, it builds, and then,hello world, okay?

that's your first .net core app. we should all do this. if you haven't done it yet,go download, install .net core sdk. create your first .net core app,it's fun, it's really easy. all right, we can do these samesteps also from visual studio code. so visual studio code has somenice features for these things. i can close that one. notice that the second notificationthat it gave me is that it's saying that there's some assets that itneeds so that you can build and

run from within visual studio code. all right, let's go ahead andadd those, and it's gonna add a little folder herewith some vs code gobbledygook. but what that enables,which is really nice, is now i can add things likebreak points from within vs code. remember, this is cross-platform. they can do this from your mac. i can go to the debug tab, and i can actually now run thisapp from within vs code.

and if all works according to plan, you should see thatbreakpoint getting hit. starting debugger, it's attaching, boom, so it hita breakpoint from within vs code. we can continue on our merry way,and we should see hello world, that worked, okay? so that's the nice thingyou get from vs code. all right, that's our briefintroduction to .net core, and we wanna do asp.net coredevelopment though, right?

so let's make this nowan asp.net core application. now the first thing you gottarealize is that an asp.net core app is just another console app. asp.net core is justa bunch of packages. it has a hosting model. it has a server, but you just wirethat up in whatever process you want, andyou've got an asp.net core app. so first, we need to addthe asp.net core packages. so i'm gonna go into my dependenciesnode, i'm gonna add kestrel.

remember that's ourmanaged web server, so microsoft.aspnetcore.server.kestrel. that's the kestrel package. and again, some nice intellisense here onthe versions that are available. i'm gonna grab 101, that's the latest version weshipped just about a month ago. and we'll save, and vs code detectsthat i need to restore packages. i could go back to the commandline and do it there,

but since vs code is helping me out,i'm gonna let it do it. so we pull down kestrel,restore is complete, good. all right, so now we need toset up asp.net core hosting. to do that, we're gonna create ahost using the webhostbuilder, okay? and i think i need someusing statements here, hopefully vs code willhelp me out with that. it does, awesome, okay. so, what are we gonna dowith this webhostbuilder? first, we're gonna tell itwhich server we want it to use.

and we're gonna use kestrel, that'sthe one that comes out of the box. you don't have to use kestrel. if you want to writeyour own hp server and plug it into asp.net core,you're more than welcome to. that would be great, you couldshare it with the community. it could be the next hot hb server, we actually are shipping anotherone for an upcoming release. we have a new server that isbased off of hbsys in windows, it's a windows only server, butwe call it our web listener server.

so if you wanna take advantageof hbsys features on windows, we're gonna make thatavailable to you. but i'm just gonna use kestrel. okay, and now i need to configurewhat i want my app to do, configure is the verb. configure, and i can just put a little delegatehere that defines what my app does. you can see it says i need todefine an action that takes an iapplication builder.

so that's what this appvariable is gonna be, is that iapplication builder. and this app is gonnabe super simple, we're just gonna doasp.net core hello world. it's gonna take in the request,request comes into the pipeline, and it's going to just write outsomething to the response. write a sync, everythingin asp.net core is a sync. hello from asp.net core, okay, and i probably need toresolve some name spaces.

vs code's gonna helpme out with that. good, try again. there we go, all right. so that's my app logicin that configurement. i'm using this app builder to saywhat do i want the request pipeline to look like. and i just have one little thing inthere that just returns hello world to the response stream. okay, now we need to build our host,so build, and that's it.

all right, now that we have a host,we need to get it going. so let's start this thing forrequests, so i'm gonna call .run on the host. and if you missed it, soit said, runs a web app, blocks the calling threaduntil the host shuts down. that's what we want, okay? like that, and that's it. that's our first webapp using asp.net core. it's about 10 lines of code or so.

so we save that, and let's run it. i'm gonna run it fromthe command line, dot net run. it's gonna build,built without errors, that's good. and it says,we're hosting a production. this is our content root path. we'll talk more aboutthat in a second. and we're listening on port 5000. hit ctrl+c to shut down, okay. so let's now open an impartialthird party browser.

i'm gonna do local host 5000. all right, there, sohello from asp.net core. so it's pretty simple, okay? so hopefully that gives you an ideaon just how you get started and the things that you need. i'm gonna shut downthe server by hitting ctrl+c. and at this point, so,this is good for simple, just quickly getting started ordoing hello world demos. by the way, the steps i justfollowed, if you want to

follow along with them,you can go to asp.net, get started. and the same steps that i just did,they're all right here, you can just do them yourself. and you should,everyone should go try it out. now there's actually a betterway though to define your application startup logic. you can define it as a class,and so i'm gonna do that next. but at this point, i think we'regonna transition over into vs, so you can see the visual studio tool.

all right, i think i should,let's close this guy. all right, sonow i'm in visual studio. i've already installed alsothe .net core tools for vs. now i'm just gonna do,file > new project. all right, so web is what we want. and let's make this a little bigger,so you can actually read it. we've got a few optionshere under web. we have the existing .net frameworksystem web, set up technologies, web forms, nvc, waypi, and so forth.

and then we have thesetwo asp.net core options. the first one says,i want to run on top of .net core. okay, so that will be an app that can thenbe taken crossplatform if you want. you can develop on windows and even publish it to a linuxmachine if you'd like. the second option is i'd like towrite an asp.net core app, but i wanna run it onthe full .net framework. and that allows you to reuseexisting binaries that you have or

third party dependencies thatdon't yet support .net core. many third parties are rapidlyadding .net core support, but in some cases,you might not have that yet and so that could be an option for you. i'm gonna use .net core, and let's just create an empty web app,go. all right, so, hopefully a lot ofthings in this app will look very familiar based on what we just did. let's see, okay, so first of all,while vs creates a project,

as soon as it's done creating, it'sgonna kick off a restore for me. and i can actually see the output ofthe restore by clicking the output link, and this is restoring thepackages that my app needs to run. now let's look at program.cs. so this should look very familiar. there, we've got our webhostbuilder,and we're saying we're using kestrel. we're building it andrunning the host. there's a couple of extraconcepts in here, and

i'll go through those real quick. the first is that thisidea of a contentroot. the contentroot of yourasp.net core app is the path, where all of your apps' stuff lives,like your static files, your javascript files,your css, your html files. those generally will be served froma path that's relative to your contentroot. that path actually has a specialname, we call that the web root. and by default,the web root is wwwroot,

relative to wherever yourcontent root path is, okay? now, you can actually changeeither of those things. if you want your contentrootto be someplace else, you can tell the host, i want you tofind stuff at this other location. by default, the contentroot will actually be thelocation of your application binary. so you remember when we builtthe app, there was that bin direct? did i show, i don't actuallyremember if i showed that. let me go back.

okay, great, sowhen you build the app and i didn't even actuallydo this independent. i was doing dot net run,which does both the build and a run. if you just want to build yourapplication without actually running it, you can do that byjust doing dot net build. that just does a build. when you do a build,you will get a bin directory. and that's where yourapplication binary lives. and this is your defaultcontentroot for your app.

and there's a coupleinteresting things in here. there's the dll that got built,the pdbs. there's a couple of json filesthat are used at run time. this first one is a dependency file. that gets sort of like a miniversion of the project log file that we saw earlier,but use that runtime. these are the runtime config files, these have settings that canbe used by the runtime, like i think if you wanna turn on servergc, i think it will show up here.

for the most part, you can ignorethem, they're advanced concepts. but this is where yourcontentroot will live. by the way, during development, all your dependencies are livingin your user profile nuget folder. when you are ready toactually take this app and publish it to production, youshould run a .net publish command. cuz you wanna take all the defensesout of your nuget package folder, collect them together intoa single directory, so then you can movethem someplace else.

that way,when you're publishing your app, you don't have to run a nugetrestore on your server to get all the things that it needs to run. so a couple of things first, if iwant to run a built app directly, you can just point .net.xe directlyat the binary that you want to run, and let's now justrun the application. as you just saw there,it started up my asp.net core app. if you wanna publish,we just do .net publish and that will collect up all the dependenciesand put it in a single folder.

by default, it looks like it put itunder this published directory in the bin directory. let's look at that. yep, there it is, and now you'll see there's a lotmore binaries in here, right? all the binaries needed from thenuget packages that you restore got collected together intothat published folder. and you can just takethat folder now and copy it wherever you want it to go.

okay, couple extra concepts there. okay, so contentroot, that's whereyour app will find its stuff. now because by default, it's thedirectory of your app binary well, usually, my project, like from thestuff that's in my source control, is not going to be livingdown in bin, right? it's going to bea couple folders up. so, as a way to handle that issue,most of our templates will actually set the current directory, whereverthat is, for the content route. that way you can leaveyour static files.

and your nbc views rightthere in your project. and then,at run time it can still find them. so that's what this is doing. it's setting the content root. if you wanna set the web root tobe something other than wwwroot, you could do that as well. you could use webroot and set ininto, i don't know, like foo or whatever. that's possible. okay?

useiisintegration, what is that? remember, asp.net core appsare just a console app. but, we highly recommend thatyou run them behind some sort of production web server. some sort of mature web serverthat's really ready for internet-facing traffic. we don't actually recommendtaking kestrel and sticking it directlyon the internet yet. we're rapidly in the processof hardening kestrel and

making it stable enough andready to do that, but right now, it's missing a few things that youwould really need to make sure that it can handle any sort of malicioustraffic that could be thrown at it. so for the time being, we recommendthat you run kestrel behind something like is, or you runit behind something like linux. you could use engine x, or ha proxy,some other mature web server. with ies, the way that's done is weprovide you a native module that we call the asp.net core module. and all that module does is whena request comes in, it goes off and

fires off a process, whatever process reallythat you tell it to start. in this case, we always tellit to start and run my app and that will then fire upkestral inside that process. and then, the core asp.net coremodule will take any requests that it receives and just forwardthem along to that process. and there's a handshakethat has to happen there so that the process canreceive the request and know that it's not coming fromsomeplace else, someplace other than

is, that's what thisuseiisintegration line is doing. it's enabling that handshake. and i'll go over it in moredetail exactly what that does later this week. but for now, you can just know thatif you're running iis, it enables that integration, if you're notusing iis this line of code is actually completely benign, itdoesn't really do anything at all. so you can just leave it there. and that's why we put it in.

and then lastly,here's the normal pattern for defining your start up logic,which is to use a start up class. so instead of saying dot configure,and having a bunch of delegates in linewhen you're hosting logic, you can define a separate class that defineswhat your application actually does. so let's now go takea look at start up. okay, sothere's our configure method. and it takes an applicationbuilder just like we saw before, it also has the option of takingadditional parameters that

are services providedby the hosting layer. so for example, if you want to knowwhat's my content route at runtime, you can use this ihostingenvironment service to know things like what's my content route,what's the web root folder name? so you can resolve pass andthose sorts of things. you can see it's also gettingaccess to a logger factory. there's logging plumbsthroughout the system. and then in here, we defineour request handling pipeline. this is where we'regonna use middleware.

the request handling pipeline isjust a bunch of middleware, and they're ordered. each middleware gets a chanceto see the request and decide what it wants to do with it,asynchronously. and this app has a fewmiddleware in it. first, it's just setting up somelogging, that's not middleware. the first middleware isthis one where it's saying, i'd like to use the developerexception page. and it's in this ifblock that says but

only if i'm inthe development environment. so what does that mean? the developer exception page, maybe you all are familiar withthe yellow screen of death, right? in asp.net, something badhappened on your server and when you're in development, there'sthis nice feature where there's something in the asp.net pipelinethat will catch that exception and then render details aboutthat exception to html. so you can actually seeit in the browser, so

you can figure out what went wrong. otherwise, you just get500 in no details and that can really be frustrating. so during development, that a superuseful feature to have, but when you go to production, you don'twanna be telling the whole world about the cause that of yourentire app implementation. so that's the feature you reallyonly want to use in your development environment. so this use developersexception page middleware.

it's a piece of middleware thatdoes that same task that the yellow screen of death used to do. it catches the exception, andrenders some nice html so you can see detailsabout the exception. let me show it you real quick. if i run this app withoutchanging anything, we're just gonna get helloworld! like we had before. okay, there's helloworld!

and now, if i have an oopsie in my run method down here, okay, and then, i refresh. now, i'm not actually building here. one of the nice things that thevisual studio tooling does is it has a filewatcher. that need to throw it. there we go, there's a file watcherthat will watch all the c# files in your project and if they change,then, it will actually tear down

the process and rebuild it andget it starting again so you don't have to keep doingbuild and f5 and build and f5. you can just refresh in the browser,it's pretty nice. and so this is the blue and grey screen of death inthe asp.net core, right? so we get some nice details aboutthe exception, where it occurred. you can see details about anycookies or query string parameters, the headers on the request. it's pretty nice, not too bad.

one nice feature that a lot ofpeople don't notice is down here at the bottom. often, you need to copy the stacktrays from the exception from this page and post it on stackoverflow or put in a github issue, so you can tell us about it. and if you just click this link toshow the raw exception details, here's something that you canjust conveniently copy and paste into the [inaudible] sothat's kinda useful. now, this page should only showup when i'm in development.

now, what does that mean? well, in asp.net core,there's a first class notion of the environment,what environment are you in. that's defined by the host. if we go back to our hosting layerand i say here use environment, i don't know, staging. i just changed my environment. now, i refresh the browser. i'm no longer ina development environment,

i'm in some other environment. now, i just get a 500, i don't getany details cuz i'm no longer in that development environment. this is development check, is seeing what environment are youin and only running, adding this middleware to the pipeline if youare in the correct environment. now, statically hard codingwhat environment you're in into your hosting logic isprobably not that useful. that's why there's alsoan environment variable that you can

specify to say what environmentthe app should be currently in. and actually, that's how visualstudio specifies that when you're running in visual studio,you're in development environment. if i right-click on the project andlook at its properties, visual studio has this nice thingthat are called launch profiles, which, when you hit a five,these are the setting that you want to use when youactually run your app. this app is set up to useis express, and you'll notice, it's also set up to specifythe aspnetcore_environment variable.

and it says i'm in development. if you don't specify anything, if you don't say whatenvironment you're in at all, we'll assume thatyou're in production. so if i were just to delete this orjust change this now. actually, let's first, just sowe can see that something changed, let me make sure that we'regetting the exception page back. five and yeah, okay sowe got the exception page back and now if i go back to my properties,this should still be here, and

they change this to,i don't know, demo. i'm in the demo environment,then i go back, i refresh. i have to actually re-run the appcuz it doesn't detect your changes in your product properties, itonly detects them in the c# files. now, i'm back to a non-developingenvironment, okay? so that's your environment conceptin asp.net core, you can define your pipeline based on whatenvironment you're currently in. >> [inaudible]. >> where you getthe environment setting from,

there's a variety ofways that you can do it. so the question was, is it configurable whatenvironment you're in? do you have to use the environmentvariable or are there other ways? you can course code itin your hosting layer, you can also tell the hosting layerthat you want it to read from the configuration model. any of the settings thatare used by hosting, including what environmentsit is running in.

and i'll show what thatconfiguration model looks like, but that configuration model allows youto specify the environment using a file on disk, you could createa custom config provider that reads from a database if you wanted to. you have complete flexibilityon how to specify that. out of the box, we do give youthe environment variable cuz we think that's sort ofa convenient way to do it. good question. okay, so that's our firstmiddleware in the pipeline.

and then, there's a middleware,this really is like a little in line middleware thatjust returns hello world. let's add some more middlewareto this application. let's turn on static files. now, you might sayturn on static files, why do you have toturn on static files. well, remember everything inasp.net core is completely modular. if you want it, you have to add it. if you don't want it then don't addit but, in case of static files,

it's not there unless youactually enable the feature. so the pattern is that firstwe need to add a package, and then we need toadd the middleware. so, to add the package, i'm gonnause the new get package manager from within vs, it's kinda nice. fill in ui, and i'm gonna sayi would like static files. it's this one,this is the package i want. going to install that. and it's going to kickoff a package restore.

to bring down the package. okay, and now i just wanna showthat if we open project.json, this product.json has allsorts of stuff in it now. and have the diagnostics package, that's what brought inthe exception handling page. it has iaas integration package,kestrel, some stuff for logging. and you'll notice now it hasthe staticfiles package as well. all that nuget package managerdid was it edited project.json to add this line andthen kicked off a ran.net restore.

that's all it did. so you can just as easily dothat from the command line. but the tooling's kinda nice. all right, sowe've got the package now. now we need to add it to our app. let's go back to the developmentenvironment before i forget. so let's say app.usestaticfiles,okay? i don't have any staticfiles in this app yet. and actually, initially,i'm gonna comment this out just so

we can see it light up. in my wwwroot folder, this is the folder thatthe static file middleware looks at when it's deciding whetheror not to serve up static files. i'm gonna add just the,let's add html page. let's call it index.html andlet's put some html in here. i'm so ecstatic. get it? ecstatic? nevermind, all right, whatever.

seemed funny last night at 1 am. all right, [laugh]. so we've got a static file. okay, let's run the app. now remember,if we look at this pipeline, this request pipeline basically alwaysreturns hello world!, at the end. so, if nothing does something with arequest before it gets to the end of the pipeline it's just gonnareturn hello world!, okay. now, if i try to go to index.htmli still get hello world!,

that's because i haven't yet. enable static files. so i'm gonna enable it andif i refresh now. yes, okay sonow we got static files. now, often people assume thatthere's some notion of a default html file, right, like index htmloften is treated as a default file? that's obviously not working yetin this app. if i go to just the root, then it's not picking upindex.html as the default.

but if you want that,you can enable it, again it's just something you addto your request handling pipeline. so i can say app.usedefaultfiles(),and what does that do? that will look into your web rootand see if you have a file that has a file name that looks likea default file if it does, and the request is to the root ofthe app, it will actually modify the request url to have thatdefault file be the request url. and then the static filemiddleware picks that up and says you want me toserve up index.html.

it's a default file, sothat's what this is doing, and so now if we refresh,i should see, i'm so ecstatic! there we go, okay? so that's enabling static cloud. so that's middleware, middleware youadd the packages to get middle ware available to your app, and then youuse them in your configure method. and we have lots of middleware,middleware for routing, middleware for authentication,this is the static file middleware. okay, cool what elsedid i wanna show you?

let's talk about logging,just really quick. yeah, and we've talkedabout environments already. so logging is availablethroughout the app, it's a hosting provided service. so there's our logging factory, you can see that this app issetting up console-based logging, that was one of the packages thatwas in project.json, there's the console logger, so this willjust write the standard out, right? that's not super useful when yourrunning behind ies, cuz you don't

normally get to see the consuloutput when your running from ies. so i'm gonna add anotherlog in provider, i'm gonna add the buglogin provider. mm-hm. let's save that. when edit and save the product'scase and file in visual studio, it automatically kicks off andrestores which is great. and now let's go back to startup and now we're going tosay logger factory.

add bug. and this guy will enable freestyleto bug debugging so when you're running the app debugger it willshow up in the output window in vs. which can be really useful. you don't have to do that, like you can actually usea different launch profile, and say i don't wanna run this appduring development behind is, i just wanna run it as a normal that's whyi switcher, so i run it like this. and this will just pop up a consul,and run it as a consul app.

and you can see now i actuallyget to see the consul window and i can see the logging output. i can see things like request pathto the default index.html file, i can see when requests are startedand when they're ended, okay? end that. if i go back to is express, andwe've got a bunch of windows open. and we close all these guys. all right, let me add my ownlogging statement here as well, just to show that you can do this,too.

so logging.createlogger. let's create demo. and let's loginformationlevel stuff. i'm running. now if i run this underthe debugger, by hitting a 5, and if i look in my output window. so now i'm seeing a bunch ofdebugging information while all the symbols are getting loaded butintermixed with all those symbol load, you can seethe asp.net core logging data.

so you can see there's sayinga request got started and somewhere in here, i would expectto see, so we hit the static file middleware before it made it tothat run method but if i go to foo now we see the request got startedand there's a demo i'm running showing up at the logging output andit's at the end of the. so that's logging andthere are a lot of providers if you want to use forthose logging frameworks, as well. we're actually building a loginprovider that integrates with the azure logging infrastructureon azure app services.

so we've seen logging. i think we are ready now tograduate from the hello world!, apps to somethinga little bit more meaty. so lets do file > new project,and let's do another web app but this time we are going toclick all of the buttons. we are going to say i wanta web app, i want to change, i want individual user accounts. so this is going to give mea asp.net core app that has nbc. it has identity.

it's using entity framework core forstoring the identities and storing data. a little bit of everything. so now it's restoringall the packages. if we look at the hosting logic. that looks exactly the same,there's no change there, all right. it's just setting up the host andgetting kestrel running. if we look at start up, we've got all sorts of thingsgoing on in this start up class.

so first of all, we're waiting forall the packages to restore so those red lines go away. in the constructor there's thatconfiguration model that i mentioned previously. so it's a very simple,light weight model. the way the configurationmodel works is it have as ordered set of providers. we have providers that we giveyou for reading name value pairs from json files, from xml files,from any files, from

environment variables, so here youcan see i'm using the configuration builder to say i wanna reconfigdata from a json file, so app settings.json that's in myproject and this is just where it's getting the connection string fromand also some log settings, okay? so that's just jsonfile in your app. it's also saying if i happento have a environment specific json file then i want those settingsto overwrite the previous guy, okay? i don't have that in my app butif i had to find appsettings. development.json, thenthat would work.

this one is cool, when i'm inthe development environment it's using the usersecrets configprovider, what is that? well, one of the common fails of modern day app developmentis that, we like to use configuration for things likeapp secrets and then often those configuration files make their wayinto source control and often more people have access to that sourcecontrol than you might expect. for example, if you push it togithub, it's very easy to go searching through github and lookingfor people's connection strings and

facebook app ids andthat type of stuff. so what we did in core is we createda config provider that will instead look for config data fromsomeplace other than your project. in this case it will just pullit from a json file that sits in your user profile. so that's a really convenient placeto stick things like secrets that you're just using fordevelopment, you're not. they are not your productionsecrets they are just secretes that you wannause in development but

you don't wanna accidentallycheck into your source control. there are some placeoutside of your project. if you wanna know where that fileis is just a little of yes gesture, you can right clickon your project and say manage my user secretes andit'll open that json file and you can do thing here likesomething super secret and put your super secret password here,that type of stuff. and these values would then getpicked up by the configuration model, okay?

so that's kinda fun. and then reading fromenvironment variables. so this enables the configsystem to be environment aware. like that json file that i have, theappsettings.json where i've defined, this product template'sdefined the connection string. well when i go into production iwant to use the real production data base, right? so one way you can do that is youcan just provision an environment variable in a productionenvironment that specifies

the real connection string. that has the right config key and then the config modelwill just pick that up. will just override yourdevelopment settings. so that's one way you could do that. then builder.build createsthe actual config object. when you wanna actually get a configvalue you just do brackets and put your key here. supersecret would go there, okay?

so that's the new config model, it'senvironment aware, it's pretty nice. we use it in various places in thetemplate like here, we're using it to skip the connection string,using a little helper method. down here when setting up loggingwe're using config to get the log settings, it's just grabbing thatwhole section about logging and handing it off tothe addconsole method. and you can use itwithin your own app. okay, so that's configuration. i think it's time to talk aboutthis configure services method and

talk about di. so configureservices ismethod in startup that use to register your application services. we've seen a bunch of services thatwere coming from the hosting layer, like this hosting environmentservice or the ilogger factory. those are just services,that are just available for the fact that you'rean spi core app. but your application probablyhas services as well and you use the configure servicesmethod to register them.

so for example, this templateis registering its db context, like the any framework coredb context test or service. so it's available through dithroughout the application. it's registering the ace spent coreidentity services like the i think it's like the user store andthose types of things so that they're availablethroughout the app. it's registering the nbc serviceslike how it does action selection, how it finds the controllers,what formatters you want nbc to use. those are all configured services.

and they get added like that inyour configured services method. and of course you canadd your own services. like here we are adding a servicefor an iemail sender and one for an isms sender. these can be used for things liketo factor off indication or for account confirmation. and once you've done this, once you've registered your servicesin this way they become available via constructor injection.

now in your middleware, in yourcontrollers, in your filters, let me show you an example. we look at the accountcontroller in this template, here's its constructor. and it's taking in a wholebunch of those services, like the user manager from identity,sign in manager. there's the emailsender and thesmssender that we had seen as well. and there's the iloggerfactoryfilm from the hosting layer, you can get those here as well,okay?

so, asp.net core mbc is aware of vi,you can inject stuff into your controllers, there'sways to do it into your filters. you can even do it into your views, like if we look in the login view,in this app. at the top here you'll see there'sthis new razor directive at inject. and what this does is it says on myrazor page, i would like to define a new property and the properties ofthis type, and this is the property name, and i would like you razorto please inject the service of this type into this property soit's available to my page.

so that's how this particular pageis getting access to the sign in manager from identity. it's using this new appinject feature in razor. [inaudible] okay. and then if we look inthe configure method, this is our request pipeline. now there's a whole bunch of additional middleware thatwe haven't seen before. in addition to the developerexception page,

there's a special developererror page for the database. this guy lets you easilyrun migrations if you haven't done that yet. like if you forgot torun ef migrations, this thing will tell you to do it. you can wire a browser link. if you're not in development, like you're in production,typically then, you want to provide that oops page,you know what i'm talking about?

you know,like when you go to a server and it's blown up and they giveyou this nice page that says, i'm sorry, we're not availableright now, please try again later. this piece of middleware allowsyou to set something like that up. when this guy sees an exception,it just redirects the request up the stack to this path that youspecify and in this app that path happens to be just an actionon my home controller. which renders some view someplace i think it's under shared. yeah there it is.

it just renders someoops page that says something bad has happened okay. and that will show up in productionas opposed to in development. we've set up stack files,identity is setting up log in, we're not gonnathrough identity here. and finally we got to mbc,we do wanna talk about mbc. okay, so mbc is built ontop of routing middleware, it is built on middle ware,there's middleware happening here. there's a routing middleware thatcomes with a core it has support for

the template style route so ifyou've done mbc development before that should look pretty familiarwhere you define a template. it uses the similar conventionsthat mbc used in mbc5 so you have a controller name,you have an action name, when a request comes in you pull outsome values from the request uri to specify what controller you wantto go to and what action on that controller and then you go andcall action on that controller. some ice things though about routingin asp.net core that we now support this nice compact and tax rightwithin the route table routes.

like you can say i wanna defaultvalue by just saying equals bra. this is the syntax we've supportedwith asp routing in previous version of mvc. but now you can actuallydo it directly within your convention-based routes. similarly, if you want todefine an optionality, you wanna say a [inaudible]value in the uri. the past segment is optional. you say question mark.

before you had to define somecrazy anonymous object and use some special marker value. now you can just put it right inyour template which is pretty cool. you can do things like in-lineconstraints like if you wanna say this route should only hitif this id is an integer. you can do that. it's colon, and then the name ofthe constraint that you want to use. and there's a wholebunch of built-in ones. so this one would say,that id has to be an int. okay?

so that's convention-based routes. if we run this app,we'll just go ahead and run it so we can see what the app does. aah! what'd i do? question mark! thank you! glad someone is paying attention. it's like why does everyone keepsaying question mark, question mark.

[laugh]>> [inaudible] >> yeah that's why i was getting nervous. okay sothere is just a normal template. and you can register users. you can login new users andso forth. this is renderingstandard nbc views. if you go to the home controller,you may have seen it briefly before. this is just returning view and

we've got a bunch of viewsinside of the views folder. so that's standard nbc web ui andthat's virtually unchanged. if you have an mvc app today, andyou want to port to asp.net core, for the most part youshould be able to copy and paste your controllers andviews into a asp core app. and those controllers and views you should pretty muchnot have to change at all. you may have to change the namespace, like instead of system mvc, the name space is now microsoft.hpnetcore or something like that.

but other than that the codeis pretty much the same. the one thing that's differentis now you can do web api logic in the same model. it's the same controller model, it'sthe same underlying infrastructure. so, for example, on my home controller let'sdefine a little web api. i'm gonna do, actually beforei me ti find a little models type so let's call it a classvalue prop int id. let's give it some sort of textvalue there that's a simple little

value and we gonna have a littleweb api end point that returns a value and it's gonna take an id. and let's return a new value. and let's just copy the id in. and then we'll use a little bitof string interpolation here, value (id) okay? that's just c# 6 index. all right, good. now, you can use attribute routingdirectly within asp.net core nvc.

so i'm going to put an attributeroute on this action. and say that this guy should onlyrespond to get requests to api/id. no, api/value/(id),that will be better, okay great. okay did i forget something? >> [inaudible]>> thank you, text = $"value, okay good. all right, so now, i should beable to go to api/value/123, doesn't really matter andthere we go. we get some json.

so i'm returning just an object. that object will get formatted using the set of formatters thatyou've configured in the system. very similar model to whatwe had with acenet web api. by default the adjacentformatters there if you want xml you can add it. if you want to add your ownformatters you can do that. okay, so that's act reroutingdoing web apis with nbc. often with web apis, it's nice tohave some metadata about your web

api and maybe a help page thatdescribes your in points and what they look like we don't have metadata support built intoasp.net core out of the box. but there's a nicestandard our there. it's called swagger, which is afairly popular metadata format, for web apis. and there's a great communitypackage that you can use to add swagger support, to your apis. let me show you that, really quick.

so i'm gonna do managenuget packages. the name of the community packageis called swashbuckle, so we're going to add some swagger to thisswashbuckle, so that's pretty cool. all right, let's see if we can findit i want to browse not install, there it is,i'm gonna install this guy. so swashbuckle will give you twothings, it'll give you both like the swagger json representationof your api end points and it will also give you a nice littleui that you can see your api, you can actually test it withinthe browser, it's pretty convenient.

alright, so it's restoring and thenwhile it's doing that i wanna go to startup andwe're gonna add swagger to our apps. so first i'm gonna add the servicesthat swashbuckle uses, so i'm gonna say services.add soyou add services, okay, you use middleware add services, those are the services thatswashbuckle needs to function. and then down here, we'll add somemore middleware to our pipeline, we're gonna say app.useswagger,so that'll add middleware to the pipeline that enablesthe json meditative format and

then app.useswaggerui, that will add the nice help page andlittle in browser test client, okay? all right, i've saved that,so now, i believe, i think the uri's that those guysuse by default is swagger/v1/, the version and then swagger.json. see, you see a whole bunchof json stuff, we do, okay. so that's the machine readabledescription of my little tiny api. if i want to see the human readableversion i can go do swagger/ui and there we go, sonow we've got a little browser view.

there's my end point, api value,the id, it shows me the schema of the response entity, it shows mewhat content types are supported. i can even try it out,like if i do 321 here and try it out, it'll actually querythe api, show me the response, show me the headers,so that's kinda fun. and then you can use the machinereadable metadata format to do things like, okay, if you wannagenerate a client you can do that. there are frameworks available fordoing client-side generation. one of them is called auto-rest,we haven't seen all the rest but

it's cool there's even some vs,visual studio tooling for running all the restwithin projects. i think with .net core projectsit's not enabled yet but you can run it from the commandline, an interest of time i think were gonna skip showingthat but it's pretty nice. it'll generate you a client proxy, you'll see that there'sthis type called value and generate you a value type that youcan just use to call your api. okay, so that's your buildingapis with asp.net core mvc.

let's take a look at some ofthe other mvc features in the views, there's a bunch of new stuffthat's available in the views. let me go back to home andpull up about. okay, sothis is just the about page, this is the about page in razor. one of the nice things with isthat we support c# 6 syntax, so if you wanna say,var me = danroth27 or whatever. and then i want to use some inspring interpolation from within my view.

that works, you can see thatintellisense is lighting up nicely, if i save and refresh,it should see about danroth27, yep, so that works, so that's c# 6, everything is asynchronous insideof views if we look in like layout there's a new razer directive thatyou can use which is add await. so you can await acesynchronous logic, where is it. like for example if i want to rendera partial view within my view, that's now an asynchronous callbecause the whole razer rendering pipeline is asynchronous.

so you can call at await to await asynchronous logic withinyour views that's kinda fun. what else do i wanna show? and then tag helpers, let's lookat tag helpers, my goodness, tag helpers. so to motivate tag helpers i thinkwhat i really need to do is first show you the way the world used tobe, right, the way it is today. do i have it here,do i have to open, let me open the. what i'm gonna do, is i'm gonna openthe login view, as it was done,

with nvc five. okay? let me, i think i have it, projects, nvc five default,yeah, that's the one we want. let's look at the log-in view asyou would do it with nbc five. so, this was hot whenwe shipped it last. so, i don't want toknock this too much. by the way, this entiresyntax is still supported. if you have this code,don't feel bad. this code will still run in core,we still support.

html helpers. the way you would dorazor stuff with mse 5, is you would use these thingscalled html helpers, and html helper was just a c# methodthat could render some html. and that was great, you could dothings like interact with your model through these html helpers. for example, here's an html helperthat's gonna generate me a form and it will generate a forum thatpoints to this particular action on my controller and that's cool.

there was an html upper forgenerating a label based off of your model like i want togenerate a label for the email property of my model. that's all great. where the problem startsto arise is that the way html huffers work is that they're,they're c sharp and once you go into an html helper youare basically stuck in csharp land. now if you want to customize therendered html from a html helper. well you are in csharp land.

so you have to somehow do thatwithin the html helper itself. you have to exposesome sensibility model. that allows you addcustom attributes. to the rendered tagsthat it outputted. so, for example, this label. if i wanted to changethe class on the label tag, well you could do thatwith an html helper. the way you did it is withan anonymous object and the convention was that the propertynames of that anonymous object

would get pt asattributes on the tag. and then the value of the propertywould be the value of that attribute. okay that's fine. in this case i want toadd a class attribute. well, remember i'm in c# land. and class is a reserved word in c#,right? so if i wanna define a propertynamed class well in c# you have to escape that and tell the compilerthis is not class the reserved word

this is class just a random propertyname, it's just an identifier. then the way you do thatunfortunately is with an @ symbol which happens to also be the samecharacter that you use in razor to transition between c# and html sothat's not confusing at all. this because veryapparent as a problem, like you really start lookingat things like angular where you have tons of custom attributesthat you're putting on tabs and you're trying to do that while usinghp helpers at the same time you kind of start to feel likeyou're fighting the system.

okay so lets look at how this lookswhen your using tag helpers, so here is what that same view lookslike with asp.net core nvc. the first thing you'll noticeis that it looks like html. its purple html butit still looks like html. now, this is a little vs featurethat's letting me know that, for each of these purple things, thereis a tag helper that is recognizing that tag and saying, i'm going todo something custom with this tag. i might change its content. i might swap it out forsomething else.

i might add to it,i might remove to it. all those things are possible. so for example,there is a form, tag helper. that is recognizing that, there'sthis special tag helper attribute. this isn't an attribute that's gonnaget serialized down into the html down to the browser. this is just something that the taghelper recognizes and it's gonna use to figure out what url to put onthat for the action of this form. and then,it just removes that attribute.

and then, you never see it again. here's that label again. here i'm saying label andi would like it for this particular property andthese tag helper attributes, these special properties,these are little windows of c#. so like in here i doget intellisense still. you see that, it says email? that's a property on my model. you still get that.

but now instead of like having touse that anonymous object syntax i can just use attributesas they were intended. like i can define my classattributes just as a normal html attribute. when i hit space inside of here,i get the benefits of their awesome html editor,that we have in digital studio. and we get, we can pickwhatever class that we want. so that's pretty nice. that's what tag helper are,so hopefully this looks.

simpler and more natural wayof doing your rendering logic. we have a whole bunch ofbuilt-in tag helpers. i've already shown you four, label,input tag helpers so you can specify a property if you wanted tobuy into a particular input. we look in layout, there's a wholebunch of interesting ones in here. here's a completely custom tag. don't go looking in the html filespecs for the environment tag. there is no environmenttag in html file. this is a tag helper and what it'ssaying is f the current environment

that this app is running in,remember environments? development, productionthose types of things. if our environment is development, then here is the linksthat i want to use. if i'm in staging or production, then theseare the links i want to use. okay? and so the environment tag helper willeither render its content or not and then the environmenttag is just removed and

never rendered down to the browser. that's how that works. that's the environment tag helper. there's also a link tag helper. this link tag helper in productionis saying, if i'm in production, i would like to use a cdn. see that. but if the cdn happens to be down, the fall back i wantyou to use is this guy.

i want you to go tothis guy instead. here are in fact the tests that iwant you to use to figure out if that cdn actuallycorrectly resolved or not. and so this tag helper will generatesome fancy java scripts that will figure out if cmv worked ornot, and then use your local versionif it wasn't available. so that's kinda cool. there's an anchor tag helper forgenerating links. we have a caching tag helper so youcan surround parts of your view that

are expensive, andyou just wanna cache away. this is a whole bunch ofbuilt-in ones that you can use. you can also write your own,write your own tag helper. and it is ridiculously simple to do. i'm gonna write one real quick. i'm gonna write a markdowntag helper, okay? what i wanna do is i wannabe able to write some, ever heard of markdown? markdown's like this lightweightway of writing html,

it's used on github. i wanna be able to write markdowninside of my razor view and have it render as html. so to do that let'sadd a little folder. this folder is not needed. i just for convenience sake,i'm defining a taghelpers folder. you can put your taghelperswherever you want. and that's add a new item. i wanna add a taghelper.

remember if i, yeah, okay, great. and let's call it, my goodness,time is going so fast. markdowntaghelper. so here's my markdown taghelper. it's just a class that justdivides from taghelper. and you can specify whattag you want it to bind to, or by convention, it will justuse the name of the class. like it will use markdownas the name of the tag. and then i need something thatcan turn markdown into html.

fortunately, there is a nicelittle community package available out there. the one i like to use is commonmark. this guy, yeah.it supports .net core, which is great. i'm sure there's other ones outthere, use whatever you like. okay, so restoring that,it looks good. i go back to my markdowntaghelper. so to do this i getthis tag helper output.

this represents what iwant to be rendered. so this guy's gonnabind to a markdown tag, and on the output i want tofirst get its child content. that's an async call, soactually i need to do task. processasync, we're gonna dothe async version of this. and i'm going to await, so i need to put an asynckeyword on here, looks good. okay, andvar content = that guy, okay. and now what do i wanna do?

i wanna do commonmark,i think it's commonmark.converter. and i want to convert some string,i need to get that string. how do i get that string? so the string's gonnabe content.getcontent to get the actuallystring representation. of the child of the markdown tag. that looks fine, andnow i want to actually, i want to do output.content, i want to set the content of the output to replaceit with the actual rendered html.

so i'm gonna set the html content, that comes out of thatcommon work call. does that make sense? so i am setting the html contentto whatever was there before. which hopefully waspresumably was markdown. but turned into html okay? and then lastly i want to makesure that there is no markdown tag that shows up in the output. so i am gonna say output .tagname.

tagname = null. i think that's it, okay, and i'm gonna build, build buildbuild, make sure it builds. and then we do need toenable this taghelper like, taghelper is my product. so to do that,i go into my view imports file. and this is the directive you use toadd tag helpers to your projects. so we already add in allthe built-in ones for you. i'm gonna @addtaghelpereverything that i've got in here.

what project is this? webapplication2. okay, cool. great, sonow let's go back to our about view. okay and if i start typing,markdown. you see how the toolingpicked that up? you see that?i'm not really sure how to do the zoom thing but trust me it says markdown rightthere even though it's really small.

and i can now typesome markdown here. if you don't know markdown,asterisk's mean, i think like italics anddouble asterisk's mean bold, so if i say hello,from markdown and save that. now if we go back to our about page,f5. hopefully we'll see some italictext and some bold text. woo, okay? that's a custom tag. you can write these.

write lots of them. it's really super fun. >> [applause]>> all right. [applause]>> i believe i'm just about out of time. there's lots of new stuff that'salso coming that i mentioned. url rewriting support, responsecaching support, these are all part of our 1.1 wave which we hopeto ship by the end of this year. weblistener is a new serverthat we're shipping which is

a server based off of hbsis. it's windows only but enables somewindows-only specific features. you'll be able to use middlewareas mvc filters in the 1.1 wave. that will allow you to dothings like if you want to say, i just want to compressjust this one action. i want output compression forjust this one action. you can do that with this model. precompiled views is coming. view components as tag helpers.

i didn't get to show that to you. it's pretty sweet, there's some goodvideos online you can look at for that one andimproved azure integration. in the next wave after that we'reshipping support for signalr, web api security is coming, we'reworking on a page-based programming model for that we calltemporarily razor pages, that's not its final name but that'swhat we're currently calling it. websockets is coming too. unfortunately we can'tshow you those things but

hopefully in some future talks we'llbe able to demo those as well. there's a lot of great talks here atthe conference about .net core and aspnet core encourageyou to look at. i would strongly recommend goingto see richard lander's .net core talk on wednesday. he'll give you all the detailson the underpinnings of everything i just showed you. i'll give you a really lightintroduction to .net core, and we focused mostly on the web stack.

he'll go really deep intowhat .net core is all about. ef core is gonna be discussedby rowan on thursday. and then if you wanna do a deepdive, asp.net core maybe i'll take some of those 1.1 demos i didn't getto today, output those on friday. you now have an excuse for stayinguntil friday afternoon at ignite. thank you everyone for coming. join us on github. read our docs. try it out.>> [applause]

>> and i'm happy to stick around and answer any questions you might have.

web design software visual studio Transfer File Server to Server with FTP Program. You Don’t Need to Download First

Tidak ada komentar:

Posting Komentar