2019年5月30日 星期四
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
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
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
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
修改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";
});
在Core 2.1版測試ok
Startup.cs的ConfigureServices()加入
services.ConfigureApplicationCookie(options => {
options.Cookie.Name = "NewCookieName";
});
Visual Studio 擴充功能 - EF Core Power Tools
2019年5月28日 星期二
VScode 執行ef migrations
dotnet ef migrations add init =>init可以改成自訂的名稱
dotnet ef database update
用此專案練習
https://github.com/aspnet/AspNetCore.Docs/tree/master/aspnetcore/data/ef-mvc/intro/samples/cu-final
dotnet ef database update
https://github.com/aspnet/AspNetCore.Docs/tree/master/aspnetcore/data/ef-mvc/intro/samples/cu-final
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
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,最重要的差別在於呼叫該方法後,不會等待作業完成就繼續往下執行。
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
Web Services Message Exchange Patterns
https://www.w3.org/2002/ws/cg/2/07/meps.html
这使您总共有六种 MEP (Message Exchange Pattern)可以选择:
- 数据报 Datagram
- 请求-响应 Request-response
- 双工 Duplex
- 带会话的数据报 Datagram with sessions
- 带会话的请求-响应 Request-response with sessions
- 带会话的双工 Duplex with sessions
https://www.w3.org/2002/ws/cg/2/07/meps.html
2019年5月22日 星期三
[WCF] 使用 svcutil.exe 產生合約 Client 程式碼
https://dotblogs.com.tw/yc421206/2013/10/24/125428
C:\temp>svcutil /target:code net.tcp://localhost:5000/IHelloWCF/Mex
https://www.cnblogs.com/tianzhiliang/archive/2011/08/09/2132532.html
C:\temp>svcutil /target:code net.tcp://localhost:5000/IHelloWCF/Mex
https://www.cnblogs.com/tianzhiliang/archive/2011/08/09/2132532.html
2019年5月21日 星期二
WebServiceHost有何特别之处?
https://www.cnblogs.com/artech/archive/2012/02/08/WebServiceHost.html
WebServiceHost是ServiceHost的子类,而WebServiceHostFactory是对应的ServiceHostFactory
WebServiceHost是ServiceHost的子类,而WebServiceHostFactory是对应的ServiceHostFactory
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>
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" />
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
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
无论你是new一个静态HttpClient还是通过HttpClientFactory去创建HttpClient,记得要将UseProxy=false
訂閱:
文章 (Atom)