How do you globalise the ASP.Net forms authentication longinUrl for multiple languages?


How do you globalise the ASP.Net forms authentication longinUrl for multiple languages?



I hope someone can help with solution to this problem?

Currently my ASP.Net MVC website uses forms authentication is set up like this my web.config:

<authentication mode="Forms">   <forms loginUrl="en/User/Signin" timeout="2880" /> </authentication> 

We have some routing rules that use the prefix /en/ in the url as a identifier for the language, but the problem is that if someone is visiting our french site www.web.com/fr/Secure/privateData, they are redirect to www.web.com/en/User/Signin, which in turn sets the culture to english. So after logging in, users may need to change there language back to french.

Not good!

So if the website need to suppurt more languages, so I need to do something like this in the web config:

<authentication mode="Forms">     <%if (isGerman()) { %>         <forms loginUrl="de/User/Signin" timeout="2880" />     <%} else if (isFrench()) {%>         <forms loginUrl="fr/User/Signin" timeout="2880" />     <%} else { %>         <forms loginUrl="en/User/Signin" timeout="2880" />     <% } %> </authentication> 

I know you can not have code in the web.config, but this is just to illustrate what I am trying to achieve. Could anyone provide a simple solution, or links to solutions they may already use?

Thanks alot!


Html.ValidationMessageFor on Mono has strange results

1:

how to get the string from dropdown list
Can't you just globalize one login page and show the language strings depending on the language setting?. ASP.Net MVC Blog content storage Otherwise you should use any kind of redirect, set one login page and redirect to the correct page depending on the language settings within this page. Invalidate portions of the asp.net mvc output cache - with varying levels of granularityHowever you might need to add extra code to your config telling the system this the language versions of the login are not protected within the authentication mode (you must exclude/change settings for certain parts of the site in the web.config) to prevent endless looping.. asp.net mvc c# - how to use check box in view and get its value in model?
Are there any open source ASP.Net plug-ins/modules for Vanity URLs for SEO?jquery load partial view asp.net mvc

2:

jquery post to actionresult that renders a partial view broken on deployment
Dai,. I did any thing very similar and have a basecontroller this sets the language on correct login. I dont have the code to hand right now although it's any thing along the lines of:.
    public string Lang { receive ; private set; } // at the top of the abstact basecontroller      protected override void Initialize(System.Web.Routing.RequestContext requestContext)     {         Lang = requestContext.RouteData.Values["lang"].ToString() ?? System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;         ViewData["Lang"] = Lang;          base.Initialize(requestContext);     } 
I then plug the Lang variable into the routes as required. I'll see if i must dig out the code this i use although hopefully the above will be enough to receive your head around it.. jim.


54 out of 100 based on 49 user ratings 364 reviews

*