EddyYeh
    • 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
    # ASP.net CORE MVC網站開發 ## 下載連結 https://onedrive.live.com/?authkey=%21APb%2D%2D%2DJneosbpa0&id=26903E7B74BAB5C5%213724&cid=26903E7B74BAB5C5 ## 網站概論 若有一天客戶要在家裡看到公司的word檔... ### webform淘汰原因 webform會讓你的流量變很大,因為用事件的關係。 ex:php(0.8k), jsp(1k), asp(2M) 又手機上網時間變多,網路流量計費!所以網頁不能吃太多流量。 網址上的虛擬目錄與電腦實體目錄,用web server上的router去導覽。 ### 範例下載 http://books.gotop.com.tw/default.aspx/download/AEL022900 ## 1. 從空白專案開始 ### 1.1 開專案(asp.net) ![](https://i.imgur.com/0rR1Tof.png) #### (下圖)環境資料夾代表的意義 ![](https://i.imgur.com/DppYjG9.png) ### 1.2 網址連結say hello功能 #### (下圖)Controller新增控制器 ![](https://i.imgur.com/FyXaenf.png) #### (下圖)class字尾要帶Controller ![](https://i.imgur.com/fXNjNTs.png) #### Controller中的類別名稱和方法可以當作是(網址的)虛擬路徑 ![](https://i.imgur.com/PUwhWiz.png) ### 0322早上 ### 新增物件作為vm 製作一個替身,當Tproduct重長不會影響到product。 順便做一個資料的隔絕功能 ![](https://i.imgur.com/PzFMcVc.png) ![](https://i.imgur.com/j0L9FVg.png) ![](https://i.imgur.com/h94QYIM.png) #### 網址解析 ``` https://www.kcg.gov.tw/News_Content.aspx?n=F29A02A9D36C47F0&sms=19902EF36D6B551D&s=7854A906DE1F67A5 其中 n=F29A02A9D36C47F0 是key-value關係 符號& 是and連接多個條件: &sms=19902EF36D6B551D &s=7854A906DE1F67A5 ``` ![](https://i.imgur.com/4tfdhDA.png) #### 網址帶參數 ```csharp= public string addToCart() { // Demo Request // http://localhost:61327/Greeting/addToCart/?pid=1 string id = Request.QueryString["pid"]; if (id == "0") return "XBox 加入購物車成功"; if (id == "1") return "PS5 加入購物車成功"; if (id == "2") return "Switch 加入購物車成功"; return "找不到該產品資料"; } public string demoResponse() { Response.Clear(); Response.ContentType = "application/octet-stream"; Response.Filter.Close(); Response.WriteFile(@"C:\note\01.jpg"); Response.End(); return ""; } ``` 執行結果 ![](https://i.imgur.com/z8ZNIcd.png) #### 網址帶參數 ```csharp= public string demoParameters(int? pid) { // int? 才不會因為沒參數當掉 // Demo Request // http://localhost:61327/Greeting/demoParameters/?pid=0 if (pid == 0) return "XBox 加入購物車成功"; if (pid == 1) return "PS5 加入購物車成功"; if (pid == 2) return "Switch 加入購物車成功"; return "找不到該產品資料"; } ``` 1.parameter會自動轉型 2.網址是你帶的參數 #### 取名剛好叫做id,就可以不用加上參數 ```csharp= public string demoParameterId(int? id) { // int? 才不會因為沒參數當掉 // Demo Request // http://localhost:61327/Greeting/demoParameterId/1 if (id == 0) return "XBox 加入購物車成功"; if (id == 1) return "PS5 加入購物車成功"; if (id == 2) return "Switch 加入購物車成功"; return "找不到該產品資料"; } ``` #### connection string (下圖)檢視-伺服器總管-加入連結 ![](https://i.imgur.com/WEjxlX1.png) ## controller對應view ### 一個控制器對應頁面資料夾,方法對應一個cshtml ![](https://i.imgur.com/0a52Psm.png) ```csharp= // 控制器新增方法(action) public ActionResult showView() { return View(); } ``` (下圖)新增檢視view ![](https://i.imgur.com/kjcTeaj.png) ### controller-view架構圖 1. router只負責轉資料 2. 共用的(ADO.NET)或者商業邏輯都交由MODEL層 3. 由Controller接client資料,傳給對應的model,接收response,再傳給view刷新頁面。 ![](https://i.imgur.com/tVPolWh.png) (下圖)controller傳資料到view ![](https://i.imgur.com/fblz5OU.png) ### Razor不是完全版的c#,作用在html的c# (下圖)view接收controller資料 ![](https://i.imgur.com/8Fdy8eq.png) ### 範例 ![](https://i.imgur.com/VRujoLL.png) ![](https://i.imgur.com/UOft0WL.png) ![](https://i.imgur.com/BjjsBXm.png) ## Razor如何收資料 傳資料:直接丟進view() 收資料 1. 如何取得物件參考 2. 如何取得物件型別 ![](https://i.imgur.com/vQgQnpH.png) ### h3 ![](https://i.imgur.com/8s25p0O.png) ![](https://i.imgur.com/4u8bQND.png) ### html傳資料到後端c# 1. input按鈕的type屬性打submit 2. form上面要給一個submit的範圍,method要給post 3. 可能有多個來自前端的submit,後端是認Name作為變數名稱 4. 後端抓資料用`Request.Form["<Name>"]` ![](https://i.imgur.com/dJfXH3k.png) ### 範例;前端畫面相加傳到後端運算,再回傳答案 ![](https://i.imgur.com/MOKUwtR.png) ### Html的action Link 為了讓不會html的人也能寫mvc微軟開發了此技術在cshtml。 ![](https://i.imgur.com/6Gzqfnn.png) 第一個參數:文字 第二個參數:Action 第三個參數:Controller 第四個參數:Parameters 第五個參數:JS code ```htmlmixed= count++; <tr> <td>@count</td> <td>@item.fName</td> <td>@item.fPhone</td> <td>@item.fEmail</td> <td>@item.fAddress</td> <td>@item.fPassword</td> <td><a href="~/Customer/Delete/@item.fId">刪除</a></td> <td>@Html.ActionLink("刪除", "Delete", "Customer", new { id=item.fId }, new { onclick = "return confirm('確定要刪除嗎?')"})</td> </tr> ``` ### update不用一直傳參數 1. html的name屬性跟後端物件的屬性名子一樣 2. 物件名稱直接傳進來 3. ![](https://i.imgur.com/Ieify4c.png) ![](https://i.imgur.com/uPajrzO.png) (好藏喔= =|||) ### Day4 Boosttrap ![](https://i.imgur.com/s8kIfZl.png) ### Boostrap template free ### 開始寫產品 但產生的View要用現成的entity framework ![](https://i.imgur.com/4DCsfFs.png) ### 強行別 ![](https://i.imgur.com/ZeaPzDk.png) ### 刪除的cshtml ![](https://i.imgur.com/OO8veVN.png) ### 編輯 ![](https://i.imgur.com/kYwFo8P.png) ### 編輯的cshtml ![](https://i.imgur.com/qasEzXC.png) ### 加入購物車 ![](https://i.imgur.com/JcRDUhn.png) ## Day 0320 ## 實際整合到頁面 ### create前端畫面 #### 先準備好api打到哪個function ![](https://i.imgur.com/vVzIy1A.png) #### 再來新增欄位 ![](https://i.imgur.com/u9Wighq.png) #### 更新寫資料的物件 ![](https://i.imgur.com/Io2vDmj.png) #### 後端api寫入資料庫和在Server存檔 ![](https://i.imgur.com/0yeiI9A.png) #### List前端畫面讀取時從server拿檔案 ![](https://i.imgur.com/5Xe3Gzh.png) ## 物件模型驗證 1. http的 <input required /> 2. js 3. c#物件驗證模型 ### 顯示名稱修改 這個是前端驗證喔 ![](https://i.imgur.com/O5lgAtR.png) ![](https://i.imgur.com/Od2Lun9.png) ### 為何程式碼會只執行一次 ![](https://i.imgur.com/6kFD1VK.png) ## Day 0320-2 ## 變數暫存 1. static:網頁有異地同步的功能 2. database 3. session 4. cookie session的方式,能依照不同的使用者暫存變數20分鐘 ![](https://i.imgur.com/UazSkMI.png) ### 原本方法 ![](https://i.imgur.com/dQRxM0l.png) ![](https://i.imgur.com/E2pGiLt.png) ### session方法 ![](https://i.imgur.com/NOg5R3q.png) ### cookie方法 ![](https://i.imgur.com/6TP9xBN.png) ### 實作cookie ![](https://i.imgur.com/B805BZg.png) ![](https://i.imgur.com/a6RSRrQ.png) ### 統整比較 ![](https://i.imgur.com/Zdne2B2.png) ### session寫程式 ![](https://i.imgur.com/EtybQZV.png) ![](https://i.imgur.com/BGaj23S.png) ### 好煩喔,一堆bug ![](https://i.imgur.com/IBAP29W.png) ### 檢視購物車的功能 ![](https://i.imgur.com/O9FTO55.png) ### 登入系統 ![](https://i.imgur.com/YjUF5Vj.png) ## Day 0321 ### 比較ASP.NET和ASP.NET CORE系統差異 ![](https://i.imgur.com/LEmlOTc.png) ### 安裝entity framework在neget,版本6.0.15 ![](https://i.imgur.com/fNEt6XS.png) Install-Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore Install-Package Microsoft.EntityFrameworkCore.SqlServer Install-Package Microsoft.EntityFrameworkCore.Tools ### 指令產生entity framework 參數有1. connection string, 2.entity framework套件 3. 輸出資料夾 到工具>Nuget>套件管理器主控台 Scaffold-DbContext "Data Source=.;Initial Catalog=dbDemo;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models ![](https://i.imgur.com/QPJPuot.png) ![](https://i.imgur.com/zCerT9v.png) ### Dependency Injection ![](https://i.imgur.com/Jh9Ag8Q.png) ### 上傳圖片 ![](https://i.imgur.com/8PJfghP.png) ![](https://i.imgur.com/obTZUlY.png) ![](https://i.imgur.com/N7kYhGi.png) asp.net的上傳圖片 1. httpPostFilebase 2. 與參數名稱一致 3. server實體路徑 4. 編碼型別 enctype="multipart/from-data" ### 程式進入點 ![](https://i.imgur.com/h41OISq.png) ## 業配粉專 Dtc book https://www.facebook.com/DTCbook DTC Tech https://www.youtube.com/channel/UCF8_vxMrqMyOBF6uweQbHTA 不錯的連結 https://www.youtube.com/watch?v=Trv9zED36Ao&list=PLDYKbP0m4U_V5E11IdqcobJVeeYrJhWTb ## 記錄亂搞 即時聊天室signalR ![](https://i.imgur.com/1P6AbRa.png) 微軟的Identity ![](https://i.imgur.com/VEpBe6x.png) Oauth實作登入 ![](https://i.imgur.com/donYEck.png) ## 隨機提問 ![](https://i.imgur.com/DrcgRhM.png) Q.使用者介面首頁要怎麼設計? 自己設計?使用者設計? 照操龍頭軟體的 ### 小故事 讓系統具有安全感(刪除前要先詢問 要不然橘子壓到左鍵就gg了) ~= 情侶問愛不愛我

    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 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