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()
精彩评论