By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,264 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,264 IT Pros & Developers. It's quick & easy.

Page language

P: n/a
Hi,
I'm currently developping a web site (not a web application) with asp.net
and would like to use the localization functionalities to avoid doing my
pages twice (and maybe eventually, 3 times). But I would also like the user
to have urls like www.thedomainIregistered.com/en/thepage.aspx or
www.thedomainIregistered.com/fr/thepage.aspx that would lead to the same
aspx (even if the url in the url bar stays the same) in the end but would
set the language to 'en' or 'fr' depending on the url.

Is this possible? if so, how can I do it? I mean, I thought of doing it
with a custum handler that would set the culture and then redirect, but
after the redirect, we lose the 'en' or 'fr'... I would like to keep it...

Thanks a lot

ThunderMusic
May 8 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
to have urls like www.thedomainIregistered.com/en/thepage.aspx or
www.thedomainIregistered.com/fr/thepage.aspx that would lead to the same
aspx (even if the url in the url bar stays the same) in the end but would
set the language to 'en' or 'fr' depending on the url.

Is this possible? if so, how can I do it? I mean, I thought of doing it
with a custum handler that would set the culture and then redirect, but
after the redirect, we lose the 'en' or 'fr'... I would like to keep
it...
You can put this:
string lang=Request.QueryString["lang"];
if (lang==null) lang="en";
response.redirect("www.thedomainIregistered.com/" + lang + "/thepage.aspx
");

Or instead response.redirect, you can put this code in aspx file (not
aspx.cs) and make a href link at the same way!
May 8 '07 #2

P: n/a
thanks for the answer... but it's not quite what I was searching for...
maybe I explained it wrong... ;)

What I want is the user to type
http://www.thedomainIregistered.com/en/thepage.aspx and the server knowing
that this page must be in english (so set the culture) and "redirect" the
user to http://www.thedomainIregistered/thepage.aspx and let the user think
it's on http://www.thedomainIregistered.com/en/thepage.aspx (by letting this
url in his url bar) What I need is some kind of stealth redirect. You may
actually ask me why I want to do this... it's because of the bookmarks
and/or indexing of sites in let's say, google... ;)

So I want it to stay http://www.thedomainIregistered.com/en/thepage.aspx in
the user URL bar, but I want my server to know it's actually
http://www.thedomainIregistered/thepage.aspx with the culture set to
english. I can make the other way around really easily (take the one without
a language and redirect to the one with the language), but that's not what
I'm trying to achieve...

Thanks a lot

ThunderMusic

"Tony" <To*****@gmail.comwrote in message
news:f1**********@magcargo.vodatel.hr...
>to have urls like www.thedomainIregistered.com/en/thepage.aspx or
www.thedomainIregistered.com/fr/thepage.aspx that would lead to the same
aspx (even if the url in the url bar stays the same) in the end but would
set the language to 'en' or 'fr' depending on the url.

Is this possible? if so, how can I do it? I mean, I thought of doing it
with a custum handler that would set the culture and then redirect, but
after the redirect, we lose the 'en' or 'fr'... I would like to keep
it...

You can put this:
string lang=Request.QueryString["lang"];
if (lang==null) lang="en";
response.redirect("www.thedomainIregistered.com/" + lang + "/thepage.aspx
");

Or instead response.redirect, you can put this code in aspx file (not
aspx.cs) and make a href link at the same way!

May 8 '07 #3

P: n/a
So I want it to stay http://www.thedomainIregistered.com/en/thepage.aspx
in the user URL bar, but I want my server to know it's actually
http://www.thedomainIregistered/thepage.aspx with the culture set to
english. I can make the other way around really easily (take the one
without a language and redirect to the one with the language), but that's
not what
You must use query strings (like www.mysite.com/mypage.aspx?lang=EN) and
then EN is your variable in query string - you can get it with
Request.QueryString["lang"]. After that you need to "rewrite url". I know
that it is possible, but I can't understand how. So maybe other programmers
from this newsgroup can explain how to use "URL Rewriting".
May 8 '07 #4

P: n/a
Yes, you are correct. Use URL ReWriting. (search google for hundreds of
examples).

You would enter a link like www.site.com/en/page.aspx and your url rewrite
would actually go to www.site.com/page.aspx?lang=en. Your page.aspx would
pick up the lang value and render the correct content. The page in the
address bar would continue to show www.site.com/en/page.aspx (until you
click a button or linkbutton, as your form renders to the ?lang=en page.)
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"Tony" <To*****@gmail.comwrote in message
news:f1**********@magcargo.vodatel.hr...
>So I want it to stay http://www.thedomainIregistered.com/en/thepage.aspx
in the user URL bar, but I want my server to know it's actually
http://www.thedomainIregistered/thepage.aspx with the culture set to
english. I can make the other way around really easily (take the one
without a language and redirect to the one with the language), but that's
not what

You must use query strings (like www.mysite.com/mypage.aspx?lang=EN) and
then EN is your variable in query string - you can get it with
Request.QueryString["lang"]. After that you need to "rewrite url". I know
that it is possible, but I can't understand how. So maybe other
programmers from this newsgroup can explain how to use "URL Rewriting".

May 8 '07 #5

P: n/a
ok, thanks...

I've made a http custom handler and in the ProcessRequest method, I insert
the following line :

context.RewritePath("/Default.aspx", false);

Actually, I tried setting the boolean flag to true or false without any
change in behavior but for now, no matter where I "redirect" (rewrite path)
to, I get an empty page with only this content in the source :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

Does anyone have an idea why?

Thanks for your help

ThunderMusic

"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:eh**************@TK2MSFTNGP05.phx.gbl...
Yes, you are correct. Use URL ReWriting. (search google for hundreds of
examples).

You would enter a link like www.site.com/en/page.aspx and your url rewrite
would actually go to www.site.com/page.aspx?lang=en. Your page.aspx would
pick up the lang value and render the correct content. The page in the
address bar would continue to show www.site.com/en/page.aspx (until you
click a button or linkbutton, as your form renders to the ?lang=en page.)
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"Tony" <To*****@gmail.comwrote in message
news:f1**********@magcargo.vodatel.hr...
>>So I want it to stay http://www.thedomainIregistered.com/en/thepage.aspx
in the user URL bar, but I want my server to know it's actually
http://www.thedomainIregistered/thepage.aspx with the culture set to
english. I can make the other way around really easily (take the one
without a language and redirect to the one with the language), but
that's not what

You must use query strings (like www.mysite.com/mypage.aspx?lang=EN) and
then EN is your variable in query string - you can get it with
Request.QueryString["lang"]. After that you need to "rewrite url". I know
that it is possible, but I can't understand how. So maybe other
programmers from this newsgroup can explain how to use "URL Rewriting".


May 8 '07 #6

P: n/a
Ok, I find myself having a lot of troubles with URL Rewriting and I've seen
on the net that in some situation indexers have difficulty indexing sites
because of some flaws in the url rewriting mecanism...

Does anybody have a solution to my problem? I mean, I want to be able to
localize my web site without having to dupplicate all the pages in 2-3 (fr,
en, sp(optional)) directories and so the indexers can index the right
content (in the right language) and people can bookmark the page in the
right language too. Is it something possible? I'd like to avoid dupplicating
pages because it could mean a pain in the you know what to maintain...
imagine a bug in one would have to be corrected in 3 places instead of
one...

Thanks

ThunderMusic
"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:Op**************@TK2MSFTNGP03.phx.gbl...
ok, thanks...

I've made a http custom handler and in the ProcessRequest method, I insert
the following line :

context.RewritePath("/Default.aspx", false);

Actually, I tried setting the boolean flag to true or false without any
change in behavior but for now, no matter where I "redirect" (rewrite
path) to, I get an empty page with only this content in the source :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html;
charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

Does anyone have an idea why?

Thanks for your help

ThunderMusic

"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:eh**************@TK2MSFTNGP05.phx.gbl...
>Yes, you are correct. Use URL ReWriting. (search google for hundreds of
examples).

You would enter a link like www.site.com/en/page.aspx and your url
rewrite would actually go to www.site.com/page.aspx?lang=en. Your
page.aspx would pick up the lang value and render the correct content.
The page in the address bar would continue to show
www.site.com/en/page.aspx (until you click a button or linkbutton, as
your form renders to the ?lang=en page.)
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"Tony" <To*****@gmail.comwrote in message
news:f1**********@magcargo.vodatel.hr...
>>>So I want it to stay
http://www.thedomainIregistered.com/en/thepage.aspx in the user URL
bar, but I want my server to know it's actually
http://www.thedomainIregistered/thepage.aspx with the culture set to
english. I can make the other way around really easily (take the one
without a language and redirect to the one with the language), but
that's not what

You must use query strings (like www.mysite.com/mypage.aspx?lang=EN) and
then EN is your variable in query string - you can get it with
Request.QueryString["lang"]. After that you need to "rewrite url". I
know that it is possible, but I can't understand how. So maybe other
programmers from this newsgroup can explain how to use "URL Rewriting".



May 10 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.