Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Page language

Reply
Thread Tools

Page language

 
 
ThunderMusic
Guest
Posts: n/a
 
      05-08-2007
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


 
Reply With Quote
 
 
 
 
Tony
Guest
Posts: n/a
 
      05-08-2007
> 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!


 
Reply With Quote
 
 
 
 
ThunderMusic
Guest
Posts: n/a
 
      05-08-2007
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" <(E-Mail Removed)> wrote in message
news:f1pu4o$9rb$(E-Mail Removed)...
>> 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!
>



 
Reply With Quote
 
Tony
Guest
Posts: n/a
 
      05-08-2007
> 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".


 
Reply With Quote
 
David
Guest
Posts: n/a
 
      05-08-2007
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" <(E-Mail Removed)> wrote in message
news:f1q0r7$a0o$(E-Mail Removed)...
>> 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".
>



 
Reply With Quote
 
ThunderMusic
Guest
Posts: n/a
 
      05-08-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:f1q0r7$a0o$(E-Mail Removed)...
>>> 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".
>>

>
>



 
Reply With Quote
 
ThunderMusic
Guest
Posts: n/a
 
      05-10-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:f1q0r7$a0o$(E-Mail Removed)...
>>>> 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".
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
writing a compiler for Monster language using C language Shravani C Programming 8 03-16-2008 09:36 PM
A language-agnostic language Ed Java 24 03-27-2006 08:19 PM
c is a low-level language or neither low level nor high level language pabbu C Programming 8 11-07-2005 03:05 PM
Using a Scripting Language as Your Scripting Language DaveInSidney Python 0 05-09-2005 03:13 AM
Python is the best and most popular general purpose scripting language; the universal scripting language Ron Stephens Python 23 04-12-2004 05:32 PM



Advertisments