YU-SHIH-PENG
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • Create new note
      • Create a note from template
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Write
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Save as template
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Write
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    ###### tags: `Akka` `Web` `DotNet Core` # ASP.NETCore 簡易描述 .NET Core為開源的通用開發平臺 (Source:https://github.com/dotnet/aspnetcore https://github.com/dotnet/efcore) Visual Studio 2019版本的也可以windows, Macos與Linux上安裝。 ## Framewrok架構 ASP .NET Core 是由 .NET Standard程式庫所組成。 使用 .NET Standard 2.0 撰寫的程式庫可在任何實作 .NET Standard 2.0 的 .NET 平台上執行。 ![](https://i.imgur.com/CwJlK9n.png) 紅框處 . NetCore重點描述 - 編譯/建制程式碼的工具 - .Net core和 .Net framework不同在於提供了一個所謂的dotnet cli工具(也可以稱為app host),這個工具提供了一個統一的api方便對專案做一些調整,並且提供像是build或者restore package的指令。dotnet cli提供的還是一個wrapper,以compiler來說,底層其實用的也是Roslyn (.net Compiler platform) - .Net Core Base Class Library (BCL) - .Net Core和 .Net Framework一樣,有提供了所謂的BCL。不過這個BCL其實從api的角度來說是少於 .Net Framework,畢竟為了跨平台有些和Windows綁的很死的像是Windows Form就不包括在 .Net Core的BCL。CoreBCL也稱為CoreFx - Core Common Language Runtime (CoreCLR) - 同 .Net Framework一樣,也是有個CLR用來執行 .Net Core的程式,不過這個CLR和 .Net Framework不同,因此稱為CoreCLR。 Standard對應支援版本(https://docs.microsoft.com/zh-tw/dotnet/standard/net-standard) --- ## .Net vs .Net Core 差異 ![](https://i.imgur.com/E5Les6e.png) .Net Core與.Net最大差異之所可以跨平台在於底層有CoreCLR層,可針對不同的平台設計相應的運行時為中間語言CIL提供一個一致的執行環境。.Net Core的CLR則是有真的提供由微軟support的跨平台的版本。 其二是 .Net Core使用app host (dotnet cli)將CoreCLR執行起來,而 .Net Framework則不是用app host run起來。因此,.Net Core的console 程式發佈出來是.dll做結尾而不是.exe 另外 **.NET Framework 有多個 GUI 架構和 Windows 特定的 Api 不存在於 .NET Core 中。同樣地,NET Core 有跨平台功能和dot NET Framework 缺少的 Api。** 基本上 .Net Core是一個更加**模組化的平台**,換句話說整體的速度和使用的資源更少。因此更符合現代化的Microservice的架構和Container模式執行的結構。 ![](https://i.imgur.com/Fz1ipmJ.png) ![](https://i.imgur.com/hx2yPRS.png) --- ## .Net Core功能特色 - 由程式碼決定功能(Environment Configurable) - ASP .NET Core 廣泛應用了 .NET 的擴充方法 (Extension Method),將 ASP .NET Core 的功能模組 (ASP .NET Core 的術語是 Middleware) 以擴充方法的方式附掛在 IApplicationBuilder 介面上,以 Use 開頭的方法為命名標準,所有應用程式所需要的功能都必須添加在 Startup 類別內,DNX Runtime 在啟動時會搜尋應用程式內的 Startup 物件,並喚起它內部的特定方法 (如 Configure()),以加入應用程式的功能。 ![](https://i.imgur.com/bvr2ePB.png) - 內建依賴注入(Dependency Injection) - 可在 Controller 內直接注入介面物件,輕鬆達到介面隔離輕鬆替換原本依賴的真實物件為mock物件。物件生命週期統一由 .Net達到輕鬆管理。PS:Net可以使用Autofac ![](https://i.imgur.com/SvLxCbR.png) - 代管 (Hosting) 方式 - 支援自我代管以及 Web Server 代管(Application can be hosted everywhere (because it is built on top of .NET Core)) - ex Internet information services (IIS), self-hosted in its own process, or even hosted inside Docker. - REST perspective - Hosts and servers satisfy the Client-Server constraint. - Middlewares - 組成應用程式管線的軟體,用以處理要求與回應 - REST perspective - Satisfies the Layered System constraint. ![](https://i.imgur.com/80UevLH.png) ![](https://i.imgur.com/DZDYqnX.png) --- ## .Net未來走向 ![](https://i.imgur.com/kEhuqS6.png) - NET Core 3.0 在 2019/9 發表 - .NET Core 3.1 將於 2019/11 推出,為 LTS (Long Term Support,長期支援版) - 更新:3.1 發佈時程2019/12之後 .NET Core 將更名 .NET,固定每年釋出新版,並定義雙數版號為 LTS 版,單數版號為 Current 版。 - .NET 5.0 2020/11 - .NET 6.0 LTS 2021/11 - .NET 7.0 2022/11 - .NET 8.0 LTS 2023/11 目前建議就是用3.1版本,因為他會長期維護。 各版本差異: https://docs.microsoft.com/zh-tw/dotnet/core/compatibility/fx-core 版本移轉需修改處:https://docs.microsoft.com/zh-tw/aspnet/core/migration/proper-to-2x/?view=aspnetcore-3.1 功能簡史圖(來源:) ![](https://i.imgur.com/8rHGfDt.png) --- ## Web專案檔案架構建議 ![](https://i.imgur.com/lLX6s2i.png) - 資料夾分類: - Controllers: 放所有的Controller - Views: 放所有的cshtml畫面 - ViewModels: 跟View呈現有關的資料模組 - ViewComponents: View上面的元件,比如Menu之類的 - Migrations: 使用指令搬遷的資料夾(指令自動生成) - Models: 純放poco值物件,DbContext的地方,以及各式各樣的模組,Filter資料夾等等 - Core: 未來可以模組化的類別。 - Utils: 專案內,常用的擴充方式。 - Services: 放置商業邏輯的地方,Service、Repository、UnitOfWork。 - 重要檔案 - wwwroot : 靜態檔案,一般放HTML、CSS、影像和 JavaScript - Startup: 應用程式啟動設定 - ConfigureServices : 服務的定義是可提供應用程式功能的可重複使用元件。 服務會registered在中ConfigureServices註冊,並透過相依性插入(DI)或ApplicationServices在整個應用程式中使用。 - Configure 建立應用程式的要求處理管線 - appsetting.json : 組態設定檔案 --- ## Web架構與專案架構 微軟官方提供ASP .NET Core的 Clean Architecture https://docs.microsoft.com/zh-tw/dotnet/architecture/modern-web-apps-azure/common-web-application-architectures ![](https://i.imgur.com/LMZZRm4.png) ![](https://i.imgur.com/pkqr6H9.png) 多人開發上 理想上官方提到的方法,都是個概念. 實際可視狀況調整.微軟概念是 infrastructure project 其他的 app,desktop 或 其他專案可以使用,但通常不同專案性質的,通常不會這樣設計,大部分都是一個app分資料夾.不太會分專案設計( Principles of Package Design) 若需要這樣設計須考量兩個設計點 兩個考慮切入點 第一種覆用性 第二種佈署性(是否只在同一台電腦) 除非你的其他專案,也會使用到這個專案的EF或Database,會建議分專案寫(因為符合覆用性)套用到Layer與Tiers的設計概念。若Layer,分層資料夾分類跟專案分類. 那意義又不同了,如果要對應Tiers 那就是做成專案分類(像微軟那樣),開發設計彈性就比較大.就符合Tiers設計.(以上為目前初步結論)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully