2019年5月30日 星期四

ASP.NET MVC + RSS ActionResult

https://blogs.msdn.microsoft.com/jowardel/2009/03/11/asp-net-mvc-rss-actionresult/

101 LINQ Samples

https://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b

VisualStudio輸入prop和propfull

VisualStudio輸入prop再TAB鍵產生以下程式碼
public int MyProperty { get; set; }

VisualStudio輸入propfull再TAB鍵產生以下程式碼
        private int myVar;
        public int MyProperty
        {
            get { return myVar; }
            set { myVar = value; }
        }

https://docs.microsoft.com/en-us/visualstudio/ide/visual-csharp-code-snippets?view=vs-2019
https://www.dotnetperls.com/snippet

在使用 IIS 的 Windows 上裝載 ASP.NET Core

https://docs.microsoft.com/zh-tw/aspnet/core/host-and-deploy/iis/index?tabs=aspnetcore2x&view=aspnetcore-2.2

https://docs.microsoft.com/zh-tw/aspnet/core/host-and-deploy/iis/index?tabs=aspnetcore2x&view=aspnetcore-2.2#install-the-net-core-hosting-bundle

RID清單

https://github.com/dotnet/corefx/blob/master/pkg/Microsoft.NETCore.Platforms/runtime.json

ILSpy (.NET Decompiler)

https://github.com/icsharpcode/ILSpy

2019年5月29日 星期三

WebHost和WebHostBuilder

WebHostBuilder.cs的源碼
https://github.com/aspnet/Hosting/blob/master/src/Microsoft.AspNetCore.Hosting/WebHostBuilder.cs

WebHost.cs的MetaPackages
https://github.com/aspnet/MetaPackages/blob/master/src/Microsoft.AspNetCore/WebHost.cs

ASP.NET Core 运行原理解剖[1]:Hosting
https://www.cnblogs.com/RainingNight/p/hosting-in-asp-net-core.html

What is the difference between IWebHost WebHostBuilder BuildWebHost
https://stackoverflow.com/questions/52085806/what-is-the-difference-between-iwebhost-webhostbuilder-buildwebhost

Scaffold Identity in ASP.NET Core projects

https://docs.microsoft.com/zh-tw/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-2.2&tabs=visual-studio

Migrate from ASP.NET Core 2.0 to 2.1

https://docs.microsoft.com/zh-tw/aspnet/core/migration/20_21?view=aspnetcore-2.2

2.1版新增了Razor Class Library
https://docs.microsoft.com/zh-tw/aspnet/core/migration/20_21?view=aspnetcore-2.2#replace-identity-20-ui-with-the-identity-21-razor-class-library

GDPR support in ASP.NET Core

https://docs.microsoft.com/zh-tw/aspnet/core/security/gdpr?view=aspnetcore-2.2

https://www.cnblogs.com/GuZhenYin/p/9154447.html

修改ASP.NET Core預設的cookie name

https://stackoverflow.com/questions/36562344/aspnetcore-change-cookie-name-when-using-google-authentication

在Core 2.1版測試ok

Startup.cs的ConfigureServices()加入
services.ConfigureApplicationCookie(options => {
  options.Cookie.Name = "NewCookieName";
});

LINQPad使用EFCore當作資料來源

https://1drv.ms/w/s!AsrZODw8cbHfajLJEXLaa5IrPCE

EF的方式大同小異,可參考
https://dotblogs.com.tw/yc421206/2014/07/15/145969
http://aminggo.idv.tw/blog/?p=1374

Visual Studio 擴充功能 - EF Core Power Tools

http://kevintsengtw.blogspot.com/2018/01/visual-studio-2017-ef-core-power-tools.html

開發EFCore必裝

下載
https://marketplace.visualstudio.com/items?itemName=ErikEJ.EFCorePowerTools

wiki
https://github.com/ErikEJ/EFCorePowerTools/wiki

更多工具
https://docs.microsoft.com/zh-tw/ef/core/extensions/


2019年5月25日 星期六

指令編譯WCF程式

https://www.cnblogs.com/tianzhiliang/archive/2011/08/09/2132532.html

C:\temp>csc /nologo /r:"c:\WINDOWS\Microsoft.Net\Framework\v3.0\Windows Communication
Foundation\System.ServiceModel.dll" HelloWCFApp.cs

OperationContract(IsOneWay=true)的用途

https://blog.darkthread.net/blog/wcf-survey-6/

IsOneWay是用來定義單向合約沒錯,但重點在「呼叫端呼叫WCF作業,但不期待收到任何回應」,其真正意義更傾向「Fire and Forget」(射後不理)。因此,指定OperationContract(IsOneWay=true)的方法傳回值應為void,最重要的差別在於呼叫該方法後,不會等待作業完成就繼續往下執行。

WCF六种消息交换模式

https://docs.microsoft.com/zh-cn/dotnet/framework/wcf/extending/choosing-a-message-exchange-pattern

这使您总共有六种 MEP (Message Exchange Pattern)可以选择:
  • 数据报 Datagram
  • 请求-响应 Request-response
  • 双工 Duplex
  • 带会话的数据报 Datagram with sessions
  • 带会话的请求-响应 Request-response with sessions
  • 带会话的双工  Duplex with sessions
Web Services Message Exchange Patterns
https://www.w3.org/2002/ws/cg/2/07/meps.html

WS-Addressing

https://www.w3.org/TR/ws-addr-core/

SOAP 1.2 MTOM

https://www.w3.org/TR/soap12-mtom/

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