顯示具有 Razor Pages 標籤的文章。 顯示所有文章
顯示具有 Razor Pages 標籤的文章。 顯示所有文章

2020年6月1日 星期一

TagMode.StartTagAndEndTag

https://docs.microsoft.com/zh-tw/aspnet/core/mvc/views/tag-helpers/authoring?view=aspnetcore-3.1

You can use the following markup with a closing tag and remove the line with TagMode.StartTagAndEndTag in the tag helper:
<website-information info="webContext" >
</website-information>



https://whosnailaspnetcoredocs.readthedocs.io/ko/latest/mvc/views/tag-helpers/authoring.html
[HtmlTargetElement("email", TagStructure = TagStructure.WithoutEndTag)] 
public class EmailVoidTagHelper : TagHelper
{
    private const string EmailDomain = "contoso.com";
    // Code removed for brevity
 
 ref:
https://www.cnblogs.com/dotNETCoreSG/p/aspnetcore-4_3_6_2-tag-helpers-authoring.html

2020年5月23日 星期六

InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor' while attempting to activate

 寫.NET Core遇到Unable to resolve service for type通常是忘記註冊物件給DI容器

 Startup.cs的ConfigureServices(IServiceCollection services)加入以下這一行
            //TagsHelper使用
            services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();


錯誤訊息:
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor' while attempting to activate