For my Xamarin.Forms app, I am looking for a way to check if a user has the right role/authentication status to access a page. I know Angular has route guards that can be reused for different routes to check for an authentication status. Is there something similar in Xamarin.Forms?
How can you restrict/control the navigation routes the user can visit based on login status/role?
3.7k Views Asked by Kevin van Schaijk At
1
There are 1 best solutions below
Related Questions in C#
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in XAML
- Can't open new instance of another window in my app, in WPF .NET 8
- Visual Studio throwing DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION when I try to add a log
- Deeplinking in .net Maui "Window was allready created"
- MauiApp crashes only in release mode at sideswitch android.os.DeadObjectException
- Move .net maui contents below the drawer when it's opened
- Both `TouchBehavior.CommandParameter` and `TouchBehavior.LongPressCommandParameter` are always passed as `null` to `Command` and `LongPressCommand`
- How do I change the size of a window?
- How can I force a .NET MAUI ContentView to fill the entire remaining space of its FlexLayout parent?
- How can I get this ComboBox to bind, populate the dropdown and write back selected value on update?
- MAUI-Animating each element of a BindableLayout
- Correctly set RadioButtonGroup for CollectionView in .NET MAUI
- Multiple color schemes depending on build configuration in WPF-application
- Select XAML file based on build configuration (Visual Studio 2022, WPF)
- The type was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built
- How can I tell if a control is actually Visible in UWP?
Related Questions in XAMARIN
- C# Visual Studio Android App Showing a wrong not working Keypad on Entry text
- Playing local recorded video
- What changed from xcode 13.2.1 to 14.2 that would affect an app's entitlements?
- After adding the packages of "Xamarin.Firebase.Messaging", getting error related to JAVA0000 "Compilation failed"
- C# Xamarin Android | Change Contentview from class
- Why does my LINQ query in Xamarin.Forms show less than expected content?
- My .net MAUI app works in debug mode, but "dotnet publish" doesn't work
- Xamarain support for IOS 17.4.1
- Grid Items keep stacking instead of creating a new row
- .NET MAUI TapGesture Command not working in CollectionView
- Xamarin android emulate usb PC Keyboard
- Java.Lang.IllegalStateException: 'Unable to parse composition' using Lottie in splashscreen xamarin forms (android)
- add Items (FILES) from Directory to Spinner List
- AVPlayerViewController's caption options do not update in .Net 8 tvOS app
- Printing PDF generate with Itext7 on a thermal printer Model:P80D
Related Questions in XAMARIN.FORMS
- Playing local recorded video
- NavbarAnimation.Maui With TabbedPage
- Why does my LINQ query in Xamarin.Forms show less than expected content?
- Not showing Created folder in My App directory MAUI
- IOS Release version showing error "PlatformNotSupported" because of PCLCrypto.SymmetricKeyAlgorithmProvider.GetAlgorithm()
- The type was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built
- Heart shaped image clip - rotate/scale a Geometry object
- Printing with Xam.Plugin.Bluetooth
- Unable to open another app from within Xamarin Forms Android app
- XamlC error XFC0000 : Cannot resolve type "Popup" in my xct:popup xaml file
- .NET MAUI TapGesture Command not working in CollectionView
- Xamarin android Could not receive the push notification on OnMessageReceived while swipe away app
- how to avoid silence while playing audio file in xmarin forms media player
- Net Maui Property FlexLayout.Shrink does not work as expected
- Xamarin android emulate usb PC Keyboard
Related Questions in XAMARIN.FORMS.SHELL
- Reset xamarin.forms.shell to initial page on back button
- Append a control above/upper to the Shell App bar without altering it
- Xamarin.Forms Shell Navigation Hierarchy with parameters
- Xamarin Forms Flyout menu at bottom
- Correct place to register shell page routing?
- Bug? System.ArgumentException: 'unable to figure out route for:
- How to switch pages in the Xamarin Shell without a back button?
- How to define different items in Flyout menu and bottom tabbar in Xamarin Forms 4.8 version using Shell?
- Xamarin.Forms.Shell: how to manage StatusBar color
- Navigate to a specific top tab page in Xamarin Shell
- How can you restrict/control the navigation routes the user can visit based on login status/role?
- xamarin.forms shell tabbar is very slow
- How can I customize the appearance of top tabs (ShellSection) in Xamarin Shell?
- Shell TabBar rounded corners override default background color (View) behind
- Global routes currently cannot be the only page on the stack
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Here is an example showing how you can control the visibility or navigation to your pages based on the login status of the user.
By default Shell will always displays initially the first element defined in
AppShell.xaml, in this case it will beLogin.xamlpage.In the below example "Page3" will be visible initially because by default (
Isvisible=true), while "Page2" it will only be visible when the bindable propertyIsLoggedistrue.You can handle any logic when user Log in/Log out in the
IsLogged_PropertyChanged()event.If you want several/specific or page based roles you can always create/define/design yours, use them in bindings, raise and use their property changed event to execute actions.
With FlyoutItem
AppShell.xaml
AppShell.xaml.cs
Login.xaml
Login.xaml.cs
Same thing with Tabs
In this example "Symbols" bottom tab won't be visible the same for upper tab "B" that belongs to bottom tab "Letters" until the user log-in, the remaining bottoms tabs will be visible initially.
AppShell.xaml
Edit
You may also want to add
Shell.NavBarIsVisible="False"andShell.TabBarIsVisible="false"in the Tabbar case, to the LoginPage to respectively hide the navigation bar and hide the bottom tab bar.