---
# System prepended metadata

title: c#-5
tags: [資安筆記-c#]

---

---
title: c#-5
tags: 資安筆記-c#
---
學會看手冊
---
 <td>@c.Photo</td>
 改成
 <td>@Html.Raw(c.Photo)</td>
 
 ----
 防止空格被打入<script>alert("Hello");</script>
 自動彈出例如修改密碼?
 ![](https://i.imgur.com/1yIBF7s.png)

 ---
 新增照片
  語法錯誤public IActionResult Create(Customer obj, IFormFile  photo)
要新增using要加using Microsoft.AspNetCore.Http; 

---
用HTTP這個交通工具去帶XML去

Web api用json的格式去傳檔

UI介面

Container:K8S管理容器
serverless:飛行員
nosql:你可以寫別人也可以寫.可以副本.                  但是會有點亂
API=遊戲規則

------
````<tr id="row1" style="display: none;">````
會讓資料看不到(原來有資料只剩表格)

![](https://i.imgur.com/tJTbHja.png)
```` $(function(){
                $("#btn1").click(function(){
                   $.getJSON("/Customers",function(data){
                       alert(data[0].birthday);
                   });
  
                });
            });
```` 
去抓資料
![](https://i.imgur.com/czObgBw.png)
抓到的資料是


----
要裝DOCKER
https://docs.docker.com/docker-for-windows/
要windows企業版才能裝
https://hub.docker.com/editions/community/docker-ce-desktop-windows/

![](https://i.imgur.com/rCapTIt.png)
https://download.docker.com/win/stable/Docker%20Desktop%20Installer.exe
說明
https://docs.docker.com/docker-for-windows/install-windows-home/
兩個V都打勾

會出現"鯨魚"

---
打開CMD
打docker
----

docker images 顯示是否下載過

桌機裝完裝VSCODE
![](https://i.imgur.com/nhH8hIn.png)

---
![](https://i.imgur.com/KK5ojCn.png)

---
https://code.visualstudio.com/docs/containers/quickstart-aspnet-core

CRTL+SHIFT+P
docker fi->
![](https://i.imgur.com/mThz5cr.png)

cmd打入dotnet build
![](https://i.imgur.com/Vvy1HtR.png)

WORKDIR /app
EXPOSE 80
EXPOSE 443
改
WORKDIR /app
EXPOSE 5000
ENV ASPNETCORE_URLS=http://*:5000

---
CRTL+SHIFT+P KEY build image 按
![](https://i.imgur.com/EfjPWvM.png)
---
看旁邊的魚
![](https://i.imgur.com/Pk4EJA7.png)
---
https://code.visualstudio.com/docs/containers/app-service

![](https://i.imgur.com/okMKysV.png)
![](https://i.imgur.com/48REtiN.png)
![](https://i.imgur.com/YcX0mDJ.png)
![](https://i.imgur.com/pCy2Xg4.png)
---
![](https://i.imgur.com/Txw8yMw.png)

要有容器部屬才是建成功
![](https://i.imgur.com/K5iK5ms.png)

---
Storage account 儲存體帳戶

https://portal.azure.com/#create/Microsoft.StorageAccount-ARM

![](https://i.imgur.com/XBWp50O.png)
![](https://i.imgur.com/09VXZsv.png)
![](https://i.imgur.com/XRZktkl.png)
![](https://i.imgur.com/eZhBtGz.png)
![](https://i.imgur.com/cHyOoBW.png)
![](https://i.imgur.com/pAl918n.png)
![](https://i.imgur.com/uw3XR7M.png)
![](https://i.imgur.com/AWrKRLv.jpg)
![](https://i.imgur.com/8S0SXxe.png)

---
貼在CMD
dotnet add package Azure.Storage.Blobs

程式碼貼
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;

![](https://i.imgur.com/dQqBybG.png)
---
https://docs.microsoft.com/zh-tw/azure/storage/blobs/storage-quickstart-blobs-dotnet#upload-blobs-to-a-container

貼上
 var blobServiceClient = new BlobServiceClient("連接字串");
                var containerClient = blobServiceClient.GetBlobContainerClient("photos");
                var blobClient = containerClient.GetBlobClient(photo.FileName);
                blobClient.Upload(photo.OpenReadStream());

![](https://i.imgur.com/bPTc0zl.png)

![](https://i.imgur.com/uFaVmfM.png)

取照片前面的網址
![](https://i.imgur.com/U3GCAuK.jpg)

貼到code
![](https://i.imgur.com/lwEQ0v8.png)

----
https://austincooper.dev/2020/02/02/azure-active-directory-authentication-in-asp.net-core-3.1/
---
貼上dotnet add package Microsoft.AspNetCore.Authentication.AzureAD.UI

