简体   繁体   中英

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

I want to make UWP app. In which user will login using username/password. Using these credentials an API will be hit. Which will return authenticated user. if authenticated user is returned then his profile page is shown. otherwise he should stay at login screen. Also there are more screens in my app. User data should be retained on each screen. and if new user logs in his corresponding data should be shown.

Since I am from asp.net background. Here are my questions.

1) Is this approach fine in UWP?

2) Where to save user data after login?

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

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

5) Also How to make this app to run of fix resolution (800 x 600)

Any help on this is appreciated. Sample code will be more helpful.

1) Is this approach fine in UWP?

Yes. You could achieve it in UWP.

2) Where to save user data after login?

There're multiple choices. See Store and retrieve settings and other app data for more information.

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

It dependents on your requirement. UWP supports SQLite database. See 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

You could use local app data settings . It's existed in the whole appContainer. You could get it on each page in your app. Please note that 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. 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) Also How to make this app to run of fix resolution (800 x 600)

Setting fixed size for UWP app is impossible. Please keep in mind that UWP is designed to run on different devices with differing screen orientations and sizes, but you could resize the app view. See Window resizing sample .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM