2019年5月19日 星期日

使用 Elmah 來記錄 ASP.NET 網站的錯誤

https://www.huanlintalk.com/2013/02/something-about-elmah-error-logging.html

https://blog.miniasp.com/post/2013/03/12/ASPNET-MVC-4-and-ELMAH-Integration


    <sectionGroup name="elmah">
      <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
      <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
      <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
      <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
    </sectionGroup>

上面區塊宣告的要加入Web.config否則解析xml會認不得<elmah>
錯誤碼   0x80070032
設定錯誤   無法讀取設定區段 'elmah',因為它缺少區段宣告

設定來源:

  125:   </system.data>
  126:   <elmah>
  127:     <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/Elmah.Errors" />


ASP.NET Core 的檔案上傳

net core 2.2

https://docs.microsoft.com/zh-tw/aspnet/core/mvc/models/file-uploads?view=aspnetcore-2.2

https://github.com/aspnet/AspNetCore.Docs/tree/master/aspnetcore/mvc/models/file-uploads/sample/FileUploadSample


2019年5月18日 星期六

ASP.NET移轉到ASP.NET Core-取得 Request URL 的各個部分

https://sites.google.com/site/netcorenote/asp-net-core/get-scheme-url-host

asp.net原本用Request.Url 在Core大部分需要改使用Context.Request
Microsoft.AspNetCore.Http.Extensions.UriHelper.GetDisplayUrl(Request) => http://localhost:60467/Home/About 
【Request.Url.Scheme】Context.Request.Scheme => http 
【Request.Url.Host】Context.Request.Host.Host => localhost 

【Request.Url.Authority】Context.Request.Host.Value => localhost:60467 
【Request.Url.LocalPath】Context.Request.Path => /Home/About 
【Request.Url.Port】Context.Request.Host.Port => 60467



ASP.NET 如何取得 Request URL 的各個部分
https://blog.miniasp.com/post/2008/02/10/How-Do-I-Get-Paths-and-URL-fragments-from-the-HttpRequest-object

ASP.NET內抓取網址的方式一覽表(Request)
https://demo.tc/Post/230

.NET Core迁移续集Win下莫名其妙的超时

https://mp.weixin.qq.com/s/23dFe5Kbe3ES8X1jH80B4w

无论你是new一个静态HttpClient还是通过HttpClientFactory去创建HttpClient,记得要将UseProxy=false