當我傳輸我的應用程式時(使用 Windows 身份驗證)
User.Identity.Name.Split('\\')[1];
像上面一樣。
在 iis 中拋出錯誤,但它在本地運行良好。
System.IndexOutOfRangeException: Index was outside the bounds of the array.
我啟用了 Windows 身份驗證。我哪里錯了?
uj5u.com熱心網友回復:
您使用的唯一索引是 1 因此,如果超出范圍,則陣列中必須只有一個元素,這意味著輸入中沒有斜杠。你想要的是陣列中的最后一個元素,不管是一個元素還是兩個元素,所以User.Identity.Name.Split('\\').Last()改用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/532850.html
