简体   繁体   中英

ASP.Net Web Forms LoginStatus Multiple LoginURL - suggestions?

I am developing a multi-lingual website. I am determining the requested language via a querystring variable eg: http://mydomain.com/default.aspx?lang=en

I am using two <asp:LoginStatus /> controls in my masterpage. My web.config file is set up like this for forms authentication.

<authentication mode="Forms">
   <forms loginUrl="~/login.aspx" protection="All" timeout="30" 
    name=".ASPXAUTH" path="/" requireSSL="false" 
    slidingExpiration="true" 
    defaultUrl="default.aspx" 
    cookieless="UseDeviceProfile" 
    enableCrossAppRedirects="false"/>
</authentication>

Currently when you click on a <asp:LoginStatus /> you will be redirected to my login page and the url will look something like this: http://mydomain.com/login.aspx?ReturnUrl=%2fdefault.aspx%3flang%3den

What solutions are available to me so that I can append my lang variable to my login.aspx? depending on which language is currently active?

Your login.aspx code-behind can HttpServerUtility.UrlDecode the ReturnUrl variable. Then use HttpUtility.ParseQueryString() to get the lang param.

Eg.

HttpUtility.ParseQueryString(HttpUtility.UrlDecode(Request.Params["ReturnUrl"]));

Of course in real life you'd check if that request variable even exists

HttpUtility.ParseQueryString()

HttpUtility.UrlDecode()

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