# Redirect to signup view on hosted Lock page using Auth0AuthenticationProvider

**URL:** <https://community.auth0.com/t/redirect-to-signup-view-on-hosted-lock-page-using-auth0authenticationprovider/11161>\
**Category:** Get Help\
**Tags:** owin\
**Created:** [April 26, 2018, 5:26am UTC](https://community.auth0.com/t/redirect-to-signup-view-on-hosted-lock-page-using-auth0authenticationprovider/11161 "2018-04-26T05:26:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jesperhulten](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jesperhulten](https://community.auth0.com/u/jesperhulten)\
**Post date:** [April 26, 2018, 5:26am UTC](https://community.auth0.com/t/redirect-to-signup-view-on-hosted-lock-page-using-auth0authenticationprovider/11161/1 "2018-04-26T05:26:16Z")

</div>

Hello!

I’m using the Auth0AuthenticationProvider (nuget package) to jack Auth0 authentication into my Owin app.  
The login/signup form is the Auth0 hosted Lock page.

When prompting a user to authorize themselves using the ChallengeResult class (HttpUnauthorizedResult) in the Login action the user is correctly redirected to the login screen on the hosted login page.

Now I want to be able to also redirect the user directly to the **signup** screen of the hosted login page. Browsing the documentation for Lock I came across the “initialScreen : login/signUp/forgotPassword” parameter that is used when configuring Lock. Can this parameter be passed to the Lock application on the hosted login page from the Owin Auth0AuthenticationProvider? I’ve tried passing the parameter to the /userinfo endpoint but I have a feeling this is not the correct way to do it, and it does not work.

Below the Owin config:

```
// domain, clientid and client secret configuration
....
Provider = new Auth0AuthenticationProvider
                {
                    OnApplyRedirect = context =>
                    {
                        string userInfoAudience = $"https://{MyAuth0Domain}/userinfo";
                        string redirectUri = context.RedirectUri + "&audience=" + WebUtility.UrlEncode(userInfoAudience);

                        if (context.Properties.Dictionary.ContainsKey("InitialScreen"))
                        {
                            redirectUri += "&initialScreen=" + context.Properties.Dictionary["InitialScreen"]; // "signUp"
                        }
                        
                        context.Response.Redirect(redirectUri);
                    },
... some other event handlers

```

Any advice would be appreciated!

---

<div class="post-metadata">

**Author:** ![Tolli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tolli/32/8062_2.png) [@Tolli](https://community.auth0.com/u/Tolli)\
**Post date:** [April 26, 2018, 10:23am UTC](https://community.auth0.com/t/redirect-to-signup-view-on-hosted-lock-page-using-auth0authenticationprovider/11161/2 "2018-04-26T10:23:23Z")

</div>

I was just about to post a similar question as I didn’t find any info on this yesterday. 🙂

My only client (so far) is using SAML - as a proof of concept I added the following code to the lock config on the hosted page:  
initialScreen: new URL(window.location.href).searchParams.get(“initialScreen”),  
… and manually added &initialScreen=forgotPassword at the end of the URL I’m being redirected to.  
Still have to figure out how to get the app to append the param as you’re already doing.

So perhaps this would solve your scenario as you’re already appending the value to the URL?

-Tolli

---

<div class="post-metadata">

**Author:** ![jesperhulten](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jesperhulten](https://community.auth0.com/u/jesperhulten)\
**Post date:** [April 27, 2018, 4:45am UTC](https://community.auth0.com/t/redirect-to-signup-view-on-hosted-lock-page-using-auth0authenticationprovider/11161/3 "2018-04-27T04:45:25Z")

</div>

Tolli,

I tried your suggestion and it worked. Thank you!  
I’d think that there would be some built in logic in Lock to handle these configuration options by passing url parameters (like redirectUrl), but I guess this will work too.

Best,  
Jesper

---

<div class="post-metadata">

**Author:** ![Tolli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tolli/32/8062_2.png) [@Tolli](https://community.auth0.com/u/Tolli)\
**Post date:** [April 30, 2018, 10:02am UTC](https://community.auth0.com/t/redirect-to-signup-view-on-hosted-lock-page-using-auth0authenticationprovider/11161/4 "2018-04-30T10:02:52Z")

</div>

Great to hear! 🙂

I totally agree - was expecting this to be a bit more straight-forward. Hoping someone will pitch in with more info…

-Tolli

---

<div class="post-metadata">

**Author:** ![Tolli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tolli/32/8062_2.png) [@Tolli](https://community.auth0.com/u/Tolli)\
**Post date:** [June 14, 2018, 1:40pm UTC](https://community.auth0.com/t/redirect-to-signup-view-on-hosted-lock-page-using-auth0authenticationprovider/11161/5 "2018-06-14T13:40:05Z")

</div>

Be warned that the above does not work with MS Edge or Internet Explorer at this time. I’ve changed to using the following, and then accessing parameters like parsed\_qs.initialScreen.

function parse\_query\_string(query) {  
var vars = query.split(“&”);  
var query\_string = {};  
for (var i = 0; i \< vars.length; i++) {  
var pair = vars[i].split(“=”);  
var key = decodeURIComponent(pair[0]);  
var value = decodeURIComponent(pair[1]);  
// If first entry with this name  
if (typeof query\_string[key] === “undefined”) {  
query\_string[key] = decodeURIComponent(value);  
// If second entry with this name  
} else if (typeof query\_string[key] === “string”) {  
var arr = [query\_string[key], decodeURIComponent(value)];  
query\_string[key] = arr;  
// If third or later entry with this name  
} else {  
query\_string[key].push(decodeURIComponent(value));  
}  
}  
return query\_string;  
}

```
var parsed_qs = parse_query_string(window.location.href.split('?')[1]);

```

---

<div class="post-metadata">

**Author:** ![jesperhulten](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jesperhulten](https://community.auth0.com/u/jesperhulten)\
**Post date:** [June 15, 2018, 1:17am UTC](https://community.auth0.com/t/redirect-to-signup-view-on-hosted-lock-page-using-auth0authenticationprovider/11161/6 "2018-06-15T01:17:34Z")

</div>

Thanks for the heads up! I realized this the other day when testing on Safari on OSX.

I changed the code to something similar you suggested, and it’s working as expected.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [August 27, 2019, 12:27pm UTC](https://community.auth0.com/t/redirect-to-signup-view-on-hosted-lock-page-using-auth0authenticationprovider/11161/7 "2019-08-27T12:27:04Z")

</div>


