如何在 UWP(通用 Windows 编程)应用程序中进行简单的用户登录

How to do simple user login in UWP (Universal Windows Programming) app

我想制作 UWP 应用。其中用户将使用 username/password 登录。使用这些凭据将命中 API。这将 return 经过身份验证的用户。如果经过身份验证的用户被 returned 则显示他的个人资料页面。否则他应该留在登录屏幕上。我的应用程序中还有更多屏幕。用户数据应保留在每个屏幕上。如果新用户登录,则应显示其相应数据。

因为我来自 asp.net 背景。这是我的问题。

1) 这种方法在 UWP 中可行吗?

2) 登录后用户数据保存在哪里?

3) 我应该使用 SQLlite 还是 In-memory 保存它?

4) 是否有网站中的会话这样的概念,以便我可以在每个页面上登录用户

5) 还有如何使这个应用达到 运行 的固定分辨率 (800 x 600)

感谢您对此提供任何帮助。示例代码会更有帮助。

1) Is this approach fine in UWP?

是的。你可以在 UWP 中实现它。

2) Where to save user data after login?

有多种选择。有关详细信息,请参阅 Store and retrieve settings and other app data

3) Should I save it using SQLlite or In-memory?

这取决于您的要求。 UWP 支持 SQLite 数据库。参见 Use a SQLite database in a UWP app

4) Is there any concept like Session In Websites so that I can get logged in user on each page

您可以使用 local app data settings。它存在于整个 appContainer 中。您可以在应用程序的每个页面上获取它。请注意 The lifetime of the app data is tied to the lifetime of the app. If the app is removed, all of the app data will be lost as a consequence.

5) 还有如何使这个应用达到 运行 的固定分辨率 (800 x 600)

无法为 UWP 应用程序设置固定大小。请记住,UWP 旨在 运行 在具有不同屏幕方向和尺寸的不同设备上使用,但您可以调整应用视图的大小。参见 Window resizing sample