Tag Helpers is a replacement for HTML helpers
For example, the original view model definition is this:
@using (Html.BeginForm ("Register"," Account", FormMethod.Post,New{@class ="Form-horizontal", role ="form"}) {@Html. AntiForgeryToken ()NewAccount.@Html. ValidationSummary (true,"",New{@class ="Text-danger" }) <divclass="Form-group">@Html. labelfor (M= M.username,New{@class ="col-md-2 Control-label" }) <divclass="col-md-10">@Html. textboxfor (M= M.username,New{@class ="Form-control" }) </div> </div>
In the new version of MVC, we can use tag helper to define:
<form asp-controller=" Account"asp-action="Register"Method="Post" class="Form-horizontal"role="form"> Newaccount."validationsummary.modelonly" class="Text-danger"></div> <divclass="Form-group"> <label asp- for="UserName" class="col-md-2 Control-label"></label> <divclass="col-md-10"> <input asp- for="UserName" class="Form-control"/> <span asp-validation- for="UserName" class="Text-danger"></span> </div> </div>
This is handy for front-end developers, but I have no sense because I am full Stack Develop
If you want to use it, you can refer to this article: http://www.cnblogs.com/TomXu/p/4496480.html
Now there is no outputcache attribute, instead of Microsoft.AspNetCore.ResponseCaching.
[Responsecache (VaryByHeader ="accept-encoding")] Public Iactionresult About () {}
If you want to use Varybyquerykeys, to first refer to the cache middleware, otherwise it will error InvalidOperationException: ' Varybyquerykeys ' requires the response cache Middleware.
Modify Startup.cs
, add the following code to the Configureservices and configure two methods:
Public class startup{... Public void configureservices (iservicecollection services) { services. Addresponsecaching (); ... } Public void Configure (Iapplicationbuilder app, Iloggerfactory loggerfactory) { app. Useresponsecaching (); ... }}
Migrating legacy systems to. Net Core 2.0 Diaries (7) Tag Helpers