Page language

T

ThunderMusic

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
 
T

Tony

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!
 
T

ThunderMusic

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 said:
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!
 
T

Tony

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".
 
D

David

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 said:
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".
 
T

ThunderMusic

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 said:
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 said:
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".
 
T

ThunderMusic

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 said:
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 said:
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 said:
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".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top