How to get the previous route in blazor? - asp.net-core

How do I get the previous route in blazor?
For example, we have many pages which required authentication. So when a user tries to access that page we navigate the user to the login page.
After success full login we want a user to redirect back to the page he requested.

Related

Velusia Sample - Redirect after Registration

In the sample "Velusia" provided here Github OpenIdDict-Samples, upon most of the action the user is redirected back to the client, however upon the registration, the user is sent to the server 'home/index' page. How can I make it send a user same as the login action, back to the client?
We do have the ability to specify the SignOut redirect uri, however there is no visible option for Sign In
I could as well add in a home controller for index view a redirect to my app, however i would loose the uri I started with and would have to probably redo the request

On successful password reset user stays on success status page

On successfull reset of the password from the forgot password email link, user stays at the success status screen.
On successfull password reset, I would like to redirect the user to the fusion auth login page or to my application. One way I am thinking is to write some custom javascript to automatically redirect the user but the challenge is we have 3 applications under a tenant and theme templates are specific to the tenant, how would be I able to differentiate the redirect url?

IndetityServer3 - redirect to consent page in infinite loop

It's the Identity Server 3 Standalone Implementation Part 3 by scott Brady
When I run my hybridflow client application and login ,the consent page shows.
But after I confirm my choices about the scope and click "yes,allow" button,the page redirect to consent page.
It's the network preserve log image.
enter image description here
It's the final Http RequestURL and Its Response is the consent page.
https://localhost:44302/core/connect/authorize?client_id=hybridclient&redirect_uri=https%3a%2f%2flocalhost%3a44304&response_mode=form_post&response_type=code+id_token+token&scope=openid+profile+email+roles+offline_access&state=OpenIdConnect.AuthenticationProperties%3dGIPazkL_z51B5u_wmtKMsauUJ34gMgYgAYukTOJgcMWmtASfBx-77WQfQAeTcMuAonf8NHohQTkf6gTmZIWKqBPnw3vjEf27KXPcD-q6xoDssEPwjcq_DtRck3TysSUmvF3PmqRzV2Prcukj8OJdRTOGBRUFBwXbf2_-low93P9joO_WqzC-a6M_nTG1JVy9AWUEaVPvPt1NdNU5Wwgq6A&nonce=636184232732125913.OGEyYzY4ODItYThjNi00ZDI1LWIxNDMtMTc2ZjUyNTNlYWM1MzI1ZjY2YjktMjg2MS00NDBkLTg4MDQtNDBkNzJjZWIyNTVm
Looks like the returnUrl is always pointing at your singin page, which seems to always redirect to IdentityServer. Debug thru your code and you'll see where you re-enter your signin, even after the user has been logged in.

MVC 4 Redirect from login page if authenticated

By using a default MVC 4 web application how can I redirect the user to certain page if he is logged in? What I mean when you try to access a page that is decorated with [Authorize] attribute, it will redirect you to login page and the parameter in the url is the page you tried to access. If login succeeded, you will be redirected to that specific page. Now you are authenticated and you can access that specific page. But if you go back to the login page http://page:port/Account/Login it will still display the login page. How can I redirect the user from login page if he/she is already loged in?
Should I use this in the controller GET Login action from Account Controller?
if(Request.IsAuthenticated)
{
...redirect to ...
}
You can use RedirectToAction in your controller like this:
if(Request.IsAuthenticated)
{
return RedirectToAction("Index","Home");
}

Spring security: show error 403 page instead of login form page for non-authenticated users

I've set basic spring authentication. When user comes to page and enters secured URL, login form is rendered, but I want to show error 403 page (or any other page i choose).
If I understand correctly I can't use access-denied-handler because user is not authenticated at all.
How do I show any other page than login form page to non-authenticated user, when he accesses secured URL?
When you are using form-login the default AuthenticationEntryPoint redirects to the login page.
You can override this by injecting a custom entry point using the entry-point-ref attribute.
You can use the code for Http403ForbiddenEntryPoint as a guideline (or use that directly if all you want is a response code sent to the client).
Add the below tag in your security context file.
access-denied-page="<name of the page>"
add this in http tag like below:
<http auto-config="true" access-denied-page="/authenticationfailed.jsp">