UWInfo Blog
發表新文章
[Join] | [忘記密碼] | [Login]
搜尋

搜尋意見
文章分類-#Author#
[所有文章分類]
所有文章分類
  • ASP.NET (48)
  • ASP.NET2.0 (15)
  • ASP.NET4.0 (34)
  • JavaScript (49)
  • jQuery (26)
  • FireFox (4)
  • UW系統設定 (3)
  • SQL (39)
  • SQL 2008 (25)
  • mirror (4)
  • SVN (4)
  • IE (9)
  • IIS (20)
  • IIS6 (1)
  • 閒聊 (7)
  • W3C (6)
  • 作業系統 (9)
  • C# (24)
  • CSS (12)
  • FileServer (1)
  • HTML 5 (11)
  • CKEditor (3)
  • UW.dll (13)
  • Visual Studio (16)
  • Browser (8)
  • SEO (1)
  • Google Apps (3)
  • 網站輔助系統 (4)
  • DNS (5)
  • SMTP (4)
  • 網管 (11)
  • 社群API (3)
  • SSL (4)
  • App_Inventor (1)
  • URLRewrite (2)
  • 開發工具 (6)
  • JSON (1)
  • Excel2007 (1)
  • 試題 (3)
  • LINQ (1)
  • bootstrap (0)
  • Vue (3)
  • IIS7 (3)
  • foodpanda (2)
  • 編碼 (2)
  • 資安 (3)
  • Sourcetree (1)
  • MAUI (1)
  • CMD (1)
  • my sql (1)
最新回應
  • Newtonsoft.Json.JsonConvert.DeserializeObject 失敗的情況
    test...more
  • dotnet ef dbcontext scaffold
    ...more
  • [ASP.NET] 利用 aspnet_regiis 加密 web.config
    ...more
  • IIS ARR (reverse proxy) 服務安裝
    ...more
  • [錯誤訊息] 請加入 ScriptResourceMapping 命名的 jquery (區分大小寫)
    ...more
  • 用 Javascript 跨網頁讀取 cookie (Cookie cross page, path of cookie)
    ...more
  • 線上客服 - MSN
    本人信箱被盜用以致資料外洩,是否可以請貴平台予以協助刪除該信箱之使用謝謝囉...more
  • 插入文字到游標或選取處
    aaaaa...more
  • IIS 配合 AD (Active Directory) 認証, 使用 .Net 6.0
    太感謝你了~~~你救了我被windows 認證卡了好幾天QQ...more
  • PostgreSQL 的 monitor trigger
    FOR EACH ROW 可能要改為 FOR EACH STATEMENT ...more
標籤
  • asp2121121
  • AD
  • 0F1Z8TfB
  • 9818
  • 8125
  • 776
  • 試
  • cache啟用
  • 22
  • blog
  • Line
  • windows212
  • 難
  • 6866
  • 7307
  • 472
  • sql2008
  • Viewstate
  • freetextbo
  • CPU
  • 88 ORDER B
  • ??
  • rydO6e2k
  • mrtg 連接數
  • email21211
  • 問題
  • SES
  • nu101
  • IIS 匯入
  • Server Err
  • ie
  • -3968
  • cast order
  • images
  • User212112
  • 928
  • 175
  • Config ORD
  • 使用者
  • sqlite
  • 8471-8405
  • -8048 UNIO
  • alert
  • 62 expr 95
  • inject
  • 20
  • 1569
  • 4728-4728
  • MSB1009
  • fredck.fck
頁數 4 / 12 上一頁 下一頁
搜尋 images 結果:
限制 IIS Process 的 CPU 使用量
常常會有網站不小心吃了 100 % 的 CPU.

在 appliction pool 的進階設定裡面,可以限定 CPU 使用量哦。

記得設定完 CPU 上限後,要再設定"限制動作"。

KillW3wp: 讓 process 重新啟動,這個有點爆力..
Throttle: 任何時間 CPU 使用量都不要超過限制。
ThrottleUnderLoad: 當系統的 Loading 較高時再限制 CPU 的使用量。



 
More...
Bike, 2022/3/21 下午 03:18:12
IIS 配合 AD (Active Directory) 認証, 使用 .Net 6.0
環境說明:

AD Server: dc1 (192.168.101.109)
PC: pc110 (192.168.101.110)
PC: pc111 (192.168.101.111)

第一步,把 PC 加入 AD, 這個算是基本操作,網路上說明很多, 就不再截圖了。不過在這裡還是遇到了第一個問題,解決過程請參考另一份文件: https://blog.uwinfo.com.tw/Article.aspx?Id=486

第二步,在 Visual Studio 的測試環境中測試:
一開始是使用 .Net 6.0 來實作,沒想到找到的文件都是 .Net Core 3.1 的,所以先用 .Net Core 3.1 實做了一次,後來改用 .Net 6.0 實作才成功。使用 .Net 6.0 實作的過程如下:

1. 建立一個 MVC 的標準專案: 
 
為了避免憑証問題,所以拿掉了 HTTPS 的設定


2. 改寫 launchSettings.json:
iisSettings 中的 windowsAuthentication 改為 True, anonymousAuthentication 改為 false。如下圖:
 
3. 修改 Program.cs, 加入以下四行指令:
builder.Services.AddAuthentication(IISDefaults.AuthenticationScheme);
builder.Services.AddAuthorization();
app.UseAuthentication();
app.UseAuthorization();
(注意: UseAuthentication 要加在 UseAuthentication 之後, VS 2022 應該會提示要新增 using Microsoft.AspNetCore.Server.IISIntegration;)
 
4. 在 HomeController 增加一個 Action, 以讀取驗証資料:

        [Route("GetAuthenticatedUser")]
        [HttpGet("[action]")]
        public IdentityUser GetUser()
        {
            return new IdentityUser()
            {
                Username = User.Identity?.Name,
                IsAuthenticated = User.Identity != null ? User.Identity.IsAuthenticated : false,
                AuthenticationType = User.Identity?.AuthenticationType
            };
        }

        public class IdentityUser
        {
            public string Username { get; set; }
            public bool IsAuthenticated { get; set; }
            public string AuthenticationType { get; set; }
        }
 
5. 啟動時記得要改用 IIS Express (感覺早上花了兩三個小時在為了這個問題打轉):


6. 執行結果:

第三步,在 IIS 中安裝網站:
1. 在安裝 IIS 時,記得要勾選 windows 驗證


2. 安裝 .Net 6.0 的 Hosting Bundle
https://dotnet.microsoft.com/en-us/download/dotnet/6.0
 
3. 新增網站:
主機名稱留空白 (AD 驗証在網域內好像不會使用指定的主機名稱,這個有待後續再做確認)


如果沒有刪除預設網站,會遇到警告,直接確認即可.


要把 Default Web Site 關閉,再啟動測試站
 
要啟動 windows 驗証: 
在 web.config 中增加 
      <security>
        <authentication>
          <anonymousAuthentication enabled="false" />
          <windowsAuthentication enabled="true" />
        </authentication>
      </security>



修改 applicationHost.config:

檔案位置: %windir%\system32\inetsrv\config\applicationHost.config
這兩地方的 Deny 改為 Allow
<section name="anonymousAuthentication" overrideModeDefault="Deny" />
<section name="windowsAuthentication" overrideModeDefault="Deny" />

 
參考文件: https://docs.microsoft.com/zh-tw/iis/get-started/planning-for-security/how-to-use-locking-in-iis-configuration

3. 可以取得登入資訊如下:

4. 從 Domain 中另一台主機來存取,不用登入,自動取得目前登入者的資訊。
 
5. 從非網域主機連線: 會要求認証
 

目前遇到問題: 在網域中的電腦只能用主機名稱登入,非網域的電腦,才能夠使用網址登入。

測試專案下載: https://github.com/bikehsu/AD60
 
More...
Bike, 2022/3/19 下午 09:10:08
Visual Studio ashx檔 無出現程式碼的自動完成 (Code intelligence)
2022.06.22
1) 後來發現更新這兩個檔案就可以了
參考來源:
https://docs.microsoft.com/zh-tw/dotnet/framework/install/guide-for-developers

2) 要記得把文字編輯器>副檔名的設定移除
3) 注意web.config 中 targetFramework 的版本 不能太舊
targetFramework ="4.6.1"

----------------------------------------------

最近安裝新版的Visual Studio 2022
發現ashx檔案沒有自動排版與程式碼相關名稱可以自動代入
找了一陣子才找到, 使用後發現不會檢查程式是否有錯誤..
但還是紀錄一下

開啟Visual Studio 於選單
工具>選項

文字編輯器>副檔名

 
More...
choco, 2022/2/11 上午 09:10:08
對 null 做強轉型失敗, 會造成 exception 中的錯誤行數錯亂 (C#, visual studio)
看到以下的錯誤時, 可以檢查一下是否有對 null 做強轉型. 例如: (long)xx.id, 當 xx.id 是 null 時, 就會發生以下的錯誤.

可為 Null 的物件必須具有值。
System.ThrowHelper.ThrowInvalidOperationException 
 
對 null 做強轉型失敗, 會造成  exception 中的錯誤行數錯亂: 如下圖, 錯誤應是 342 或 343 行產生, 但 Exception 郤報告 273 行.

 

 

 
 
 
 
 
More...
Bike, 2021/11/29 下午 02:06:36
Framework未安裝, 但實際上已經安裝

下載Runtime版本打開後出現, 【這部電腦已經安裝 .NET Framework 4.6.2 (含) 以上版本的更新】

後來下載Developer Pack版本安裝完畢後就可以了
https://dotnet.microsoft.com/download/dotnet-framework/net462​​​​​​​

 
More...
choco, 2021/8/23 下午 02:28:48
.Net Framework 的 Web API, AuthorizeAttribute 失效.
config.MapHttpAttributeRoutes(); 不可以放在 Startup 的 Configuration 裡面.

必需放在 WebApiConfig 的 Register 之中,  並在 Application_Start 之中執行 GlobalConfiguration.Configure(WebApiConfig.Register) 

 
 
 
 
 
More...
Bike, 2021/8/22 下午 10:15:13
在 Hyper-V 上面安裝 windows server 2019, 但無法由 iso 開機
Disable secure boot in the VM menu, that'll fix it.



from: 
https://community.spiceworks.com/topic/1719453-hyper-v-gen-2-vm-unable-to-boot-from-iso-file-to-install-os
More...
Bike, 2021/8/5 下午 09:10:51
Swagger 的問題解決 (NSwag)
在 .Net Core 的專案使用 NSwag 時遇到: Unable to render this definition, The provided definition does not specify a valid version field. 錯誤. 有點一頭霧水, 最後解決了, 大概記錄一下解決的過程:




1. 把所有的 Controller 全部移. 再開啟 /swager, 此時應該會有空的 swager 頁面, 若異常, 則應該是 NSwag 沒裝好.

2. 把 Controller 一個一個加入專案, 每加入一個, 就開啟一次 /swager 的頁面, 若是發現異常, 就是那個 controller 有問題.

3. 找到有問題的 Controller 之後, 可以把內容先全部註解掉, 然後再一個一個的把 function 加回 controller, 應該就可以找到造成問題的 Action. 該問題有可能是以下情況造成:
    A. Action 沒有指定存取的 method.
    B. 不是 Action 的 function 被設定為 public (在 Controller 裡面, 非提供 client 端存取的 function, 都不應被設為 public)
    C. 這個很神奇, 註解也有可能造成問題, 試著把該 Action 的註解刪除, 再重新加入, 說不定就會好了.



 
另外, 使用 swagger 時, 要記得在專案的屬性的建置選項中, 要勾選 XML 註解輸出, 才會自動把  Action 的註解變成說明文字.:

 
 
More...
Bike, 2021/8/2 上午 05:00:21
HTTP 錯誤 413.1 - Request Entity Too Large
 


httpRuntime 加 maxRequestLength 沒作用, 請到 system.webServer 設定 maxAllowedContentLength
<system.webServer>
...
<security>
<requestFiltering>
    <!--1073741824 ==> 1GB-->
    <requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
...
</system.webServer>

 
More...
Reiko, 2021/3/25 下午 02:36:36
用 source tree 把 branch 合併到 master 之後再建立新的 branch
1. 先切換到 master (最好是 pull 一次, 以確定是最新版本)

2. 在左側選單選點選要切換的 branch, 按右鍵. 選 Merge xxxx into current branch
 

3. 點選 master merge 前一個節點. 按右鍵, 選 Reset current branch to this branch.


4. 再來就可以比照舊的方法建立新 branch 了.


 
More...
Bike, 2021/3/13 下午 03:32:12
|< 12345678910… >|
頁數 4 / 12 上一頁 下一頁
~ Uwinfo ~