Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > สอบถามเกี่ยวกับ .NET6 การใช้ JWT และ รูปแบบการทำงานเป็นทีม



 

สอบถามเกี่ยวกับ .NET6 การใช้ JWT และ รูปแบบการทำงานเป็นทีม

 



Topic : 137027



โพสกระทู้ ( 124 )
บทความ ( 0 )



สถานะออฟไลน์




สวัสดีครับ
ขอสอบถามเกี่ยวกับการทำงานในรูปแบบทีม เนื่องจากไม่เคยมีประสบการณ์ หรือ แนวทางที่ควรจะเป็น
บน .NET 6 ++ (Web App)

1. ในการเปลี่ยน Page จะนิยมใช้ฝั่ง Server หรือ ฝั่ง Client ในการเปลี่ยน Page ?

2. หลังจากเราได้ Token มาแล้วในการเรียก Controller ทุกอันเราต้องแนบไปตลอดเลยหรอครับ หรือมี Function ที่จดจำให้ Login เพียงครั้งเดียวได้ไหม ?

3. การใช้ [Authorize] กับ Controller ซึ่งกำหนดค่า Default ให้เป็น JWT

ตัวอย่าง
C# Controller
[Authorize]
public IActionResult Select_Sections()
{
return View();
}


คำถามคือในกรณีที่เป็น Return View() ถ้า User ใส่ URL เข้าไปที่ Controller โดยตรง
ระบบจะ ERROR 401 ทันที ซึ่งจะไปไม่ถึงหน้าเว็บ ทำให้ฝั่ง Java ไม่สามารถแนบ Token ได้
มีวิธีแก้ไข หรือ วิธีที่เขานิยมใช้แบบไหนครับ ?

4. องค์กรณ์หรือบริษัทใหญ่ๆ นิยมใช้การ Login ในแบบ Stateless หรือ Stateful ครับ ?

5. การใช้ Ajax เรียก Controller ที่ Return View() และนำ Response ที่ได้มา Render เป็น Html เป็นวิธีที่นิยมไหมครับ



Tag : .NET, JavaScript, Web (ASP.NET), WebServices, Web API, MVC







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2023-05-22 08:48:15 By : evenomz View : 619 Reply : 2
 

 
จาก AI
Quote:
1. The choice between server-side or client-side rendering for page changes depends on various factors and requirements of your application. Server-side rendering (SSR) is generally preferred when you need to prioritize initial page load time, SEO, or have limited client-side capabilities. With SSR, the server generates the HTML for each page, which can then be sent to the client. On the other hand, client-side rendering (CSR) is popular when you want to build highly interactive and dynamic web applications. With CSR, the server sends the initial HTML, and subsequent page changes are handled by JavaScript on the client side. Ultimately, the decision should be based on your specific project needs and performance considerations.

2. Once you have obtained an authentication token, you typically don't need to attach it manually with every request to the server. Instead, you can store the token securely on the client-side (e.g., using cookies or local storage) and include it automatically in subsequent requests. You can achieve this by setting the token as an HTTP header, such as an "Authorization" header, in your AJAX requests or by using an HTTP client library that supports token authentication. This way, the token will be sent along with each request, ensuring the user remains authenticated.

3. When using the `[Authorize]` attribute in ASP.NET Core with JWT authentication, if a user directly accesses a protected controller endpoint without a valid token, it will result in an HTTP 401 Unauthorized response. One way to handle this situation is to perform the authentication check on the client side using JavaScript before attempting to access the protected page. If the user doesn't have a valid token, you can redirect them to the login page or perform any other desired action. By doing so, you can ensure that the user has a valid token before attempting to access protected resources.

4. The choice between stateless and stateful authentication depends on the specific requirements and constraints of the organization or application. Stateful authentication involves storing user session data on the server, while stateless authentication relies on tokens (such as JWT) that contain all the necessary information to authenticate the user. Stateless authentication is often preferred for its scalability and simplicity, as it eliminates the need to maintain session state on the server. However, there might be cases where stateful authentication is necessary, such as when additional session-related data needs to be stored or when integrating with legacy systems that rely on session management.

5. Using Ajax to call controllers and retrieve responses for rendering into HTML is a common practice in modern web applications. Ajax allows you to asynchronously send requests to the server without reloading the entire page, which enhances the user experience by providing seamless interactions. You can use JavaScript libraries such as jQuery or frameworks like Axios or Fetch API to make Ajax requests to your ASP.NET Core controller endpoints. The server can respond with JSON or HTML, and you can handle the response in JavaScript to update the page content dynamically without a full page reload. This approach is widely adopted for building responsive and interactive web applications.







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2023-05-22 22:19:41 By : 009
 


 
1. ในการเปลี่ยน Page จะนิยมใช้ฝั่ง Server หรือ ฝั่ง Client ในการเปลี่ยน Page ?
นิยมมากพอฯกัน เช่น
$("#linkXXX").on("click touchstart", function () {
window.location.href = "/ControllerName/ViewName";
});
หรือ
RedirectToAction("/ControllerName/ViewName");
หรือ ทำได้ร้อยแปดพันเก้า(รู้สี่รู้แปด)

2. - 4. ตามสะดวก ถนัดแบบไหนก็ใช้แบบนั้น

4. องค์กรณ์หรือบริษัทใหญ่ๆ นิยมใช้การ Login ในแบบ Stateless หรือ Stateful ครับ ?
นิยมใช้ SSO(Single Sign On)

ปล. เทคโนโลยีมันเก่งขึ้น มีหลากหลายขึ้น โปรแกรมเมอร์สมัยใหม่ทำงานได้ง่ายขึ้น
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2023-05-28 08:02:48 By : ผ่านมา
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามเกี่ยวกับ .NET6 การใช้ JWT และ รูปแบบการทำงานเป็นทีม
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่