Developer forum

Forum » Development » Change site language and currency "on the fly"

Change site language and currency "on the fly"

Dmitrij Jazel
Reply

Hi guys,

I asked simmilar question before, but now it's related, but a bit different.

My question is: What would be the best place (strategy) for this to work.

When user hits the website - and we can identify where he comes from, and what currency to apply - where/how should I implement this?

 

LIke first I thought of keep in in Master razor as a code snippet. - Because this is supposed to run only in the front-end. And /Admin must not be affected by this.

But I don't think that this should be a very elegant solution.

Than Global.asax Session_Start() might have been a good idea. - But this affects the /Admin, and as I said, I don't want to mess with anything that might come in a way before page load kicks in. So this did not really worked out as I expected.

 

Did not try Application_Start() in Global.asax but not sure if I can change currency while beying there, or whether that could be a great place for such code.

 

Otherwise have to think of something else, I guess.

Am hoping to hear some ideas on how you would implement this?

 

Bonus question: When managing languages, I doun't think that Subdomain like dk.xyz.com should be any different than xyz.com/da-dk/ right?

Because I find it a bit easyer to reddirect to a subdomain rather than a ISO locale, but wanted to hear your oppinion.

 


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> Than Global.asax Session_Start() might have been a good idea. - But this affects the /Admin, and as I said, I don't want to mess with anything that might come in a way before page load kicks in. So this did not really worked out as I expected. - See more at: http://developer.dynamicweb.com/forum/development.aspx?ThreadID=44852#sthash.tkTIWNjl.dpuf

Why not? Session_Start sounds good to me as it starts once per user session. Application_Start fires once for the entire app, so it won't be useful. It's easy to bypass /Admin by looking at the request URL.

Imar

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

>> Than Global.asax Session_Start() might have been a good idea. - But this affects the /Admin, and as I said, I don't want to mess with anything that might come in a way before page load kicks in. So this did not really worked out as I expected. - See more at: http://developer.dynamicweb.com/forum/development.aspx?ThreadID=44852#sthash.tkTIWNjl.dpuf

Why not? Session_Start sounds good to me as it starts once per user session. Application_Start fires once for the entire app, so it won't be useful. It's easy to bypass /Admin by looking at the request URL.

Imar

 
Dmitrij Jazel
Reply

Hi Imar,

Thanks for reply :) Yes, that is really good suggestion, will make sure to try it, but what if I need to lookup some stuff in Area properties Item tipe (for example) while I am in Session_Start?

Can those be accessible in Session_start? In ani way, thanks for the suggestion.:-)

/Dmitrij

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I think you should be able to request the area settings using the Item API: http://developer.dynamicweb.com/documentation/for-developers/item-based-structure/querying-items.aspx

Imar

 

You must be logged in to post in the forum