2020年6月22日 星期一
2020年6月21日 星期日
製作Visual Studio 2019專業版離線安裝檔
因為公司屬於企業組織,根據授權條款不能在公司使用Community版本,但公司連網際網路有管制,需要製作離線安裝檔。
事先到https://docs.microsoft.com/zh-tw/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019下載vs_professional.exe
離線安裝檔包含.NET web和.NET desktop development和Office development(繁中和英文):
請事先在D磁碟機建立vs2019pro資料夾
使用命令提示字元執行以下指令
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --add Microsoft.VisualStudio.Workload.Office --includeOptional --lang en-US zh-TW
參考資料:
https://docs.microsoft.com/zh-tw/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019
https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/install/create-an-offline-installation-of-visual-studio.md
For .NET web and .NET desktop development, run:
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --includeOptional --lang en-US zh-TW
To create a complete local layout with all features (this will take a long time—we have lots of features!), run:
vs_professional.exe --layout D:\vs2019pro --lang en-US zh-TW
For .NET desktop and Office development, run:
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.Office --includeOptional --lang en-US zh-TW
事先到https://docs.microsoft.com/zh-tw/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019下載vs_professional.exe
離線安裝檔包含.NET web和.NET desktop development和Office development(繁中和英文):
請事先在D磁碟機建立vs2019pro資料夾
使用命令提示字元執行以下指令
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --add Microsoft.VisualStudio.Workload.Office --includeOptional --lang en-US zh-TW
參考資料:
https://docs.microsoft.com/zh-tw/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019
https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/install/create-an-offline-installation-of-visual-studio.md
For .NET web and .NET desktop development, run:
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --includeOptional --lang en-US zh-TW
To create a complete local layout with all features (this will take a long time—we have lots of features!), run:
vs_professional.exe --layout D:\vs2019pro --lang en-US zh-TW
For .NET desktop and Office development, run:
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.Office --includeOptional --lang en-US zh-TW
2020年6月13日 星期六
BinaryFormatter()搭配SerializationBinder類別驗證許可還原序列化的類別
避免Unsafe Deserialization弱點
https://topic.alibabacloud.com/tc/a/-net-c--pilot-type-in-deserialization-using-serializationbinder_1_31_32345296.html
p.27
https://owasp.org/www-community/vulnerabilities/Deserialization_of_untrusted_data
https://topic.alibabacloud.com/tc/a/-net-c--pilot-type-in-deserialization-using-serializationbinder_1_31_32345296.html
//SerializationBinder的執行類
class ConversionBinder : SerializationBinder
{
public override Type BindToType(string assemblyName, string typeName)
{
//篩選Person類型
//判斷是否是Person類型,如果是返回Person_ver2
var curAssName = typeof(Program).Assembly.FullName;
var person1 = typeof(Person).FullName;
string finalType = typeName;
if (assemblyName == curAssName && typeName == person1)
finalType = typeof(Person_ver2).FullName;
return Type.GetType(finalType + "," + assemblyName);
}
}
var bf = new BinaryFormatter();
//設定自訂的SerializationBinder對象
bf.Binder = new ConversionBinder();
//序列化Person
bf.Serialize(ms, p1);
ref:
https://www.slideshare.net/MSbluehat/dangerous-contents-securing-net-deserialization?from_action=savep.27
https://owasp.org/www-community/vulnerabilities/Deserialization_of_untrusted_data
2020年6月7日 星期日
2020年6月4日 星期四
NET Core 2.1開始Identity UI被包進Razor Class Library
NET Core 2.1開始Identity UI被包進Razor Class Library
如果需要Identity Core的cshtml修改可以參考
指令產生
先安裝ASP.NET Core scaffolding engine
指令dotnet tool install -g dotnet-aspnet-codegenerator
指令dotnet aspnet-codegenerator identity
需要先用NuGet安裝以下套件(用Visual Studio的Scaffolding Item會自動安裝)
Microsoft.VisualStudio.Web.CodeGeneration.Design
Microsoft.AspNetCore.Identity.UI
Microsoft.EntityFrameworkCore.Design
Microsoft.EntityFrameworkCore.SqlServer
2020年6月3日 星期三
error CS0234: 命名空間 'Microsoft.AspNetCore.Identity' 中沒有類型或命名空間名稱 'UI' (是否遺漏了組件參考?)
因為Microsoft.AspNetCore.Identity.UI 3.1.4 只支援.NET Core 3.1以上
https://www.nuget.org/packages/Microsoft.AspNetCore.Identity.UI
所以要把專案升級到.NET Core 3.1以上
obj\Debug\netcoreapp3.0\SkillTreeRazorPageBlogSample.AssemblyInfo.cs(14,42): error CS0234: 命名空間 'Microsoft.AspNetCore.Identity' 中沒有類型或命名空間名稱 'UI' (是否遺漏了組件參考?) [D:\temptest\SkillTreeRazorPageBlogSample.csproj]
0 個警告
1 個錯誤
經過時間 00:00:03.72
RunTime 00:00:14.95
https://www.nuget.org/packages/Microsoft.AspNetCore.Identity.UI
所以要把專案升級到.NET Core 3.1以上
obj\Debug\netcoreapp3.0\SkillTreeRazorPageBlogSample.AssemblyInfo.cs(14,42): error CS0234: 命名空間 'Microsoft.AspNetCore.Identity' 中沒有類型或命名空間名稱 'UI' (是否遺漏了組件參考?) [D:\temptest\SkillTreeRazorPageBlogSample.csproj]
0 個警告
1 個錯誤
經過時間 00:00:03.72
RunTime 00:00:14.95
2020年6月1日 星期一
TagMode.StartTagAndEndTag
https://docs.microsoft.com/zh-tw/aspnet/core/mvc/views/tag-helpers/authoring?view=aspnetcore-3.1
ref:
https://www.cnblogs.com/dotNETCoreSG/p/aspnetcore-4_3_6_2-tag-helpers-authoring.html
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
https://www.cnblogs.com/dotNETCoreSG/p/aspnetcore-4_3_6_2-tag-helpers-authoring.html
訂閱:
文章 (Atom)