Page language

Discussion in 'ASP .Net' started by ThunderMusic, May 8, 2007.

  1. ThunderMusic

    ThunderMusic Guest

    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
    ThunderMusic, May 8, 2007
    #1
    1. Advertising

  2. ThunderMusic

    Tony Guest

    > 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!
    Tony, May 8, 2007
    #2
    1. Advertising

  3. ThunderMusic

    ThunderMusic Guest

    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" <> wrote in message
    news:f1pu4o$9rb$...
    >> 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!
    >
    ThunderMusic, May 8, 2007
    #3
  4. ThunderMusic

    Tony Guest

    > 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".
    Tony, May 8, 2007
    #4
  5. ThunderMusic

    David Guest

    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" <> wrote in message
    news:f1q0r7$a0o$...
    >> 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".
    >
    David, May 8, 2007
    #5
  6. ThunderMusic

    ThunderMusic Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:f1q0r7$a0o$...
    >>> 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".
    >>

    >
    >
    ThunderMusic, May 8, 2007
    #6
  7. ThunderMusic

    ThunderMusic Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    >> 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" <> wrote in message
    >> news:f1q0r7$a0o$...
    >>>> 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".
    >>>

    >>
    >>

    >
    >
    ThunderMusic, May 10, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ed
    Replies:
    24
    Views:
    971
    Dimitri Maziuk
    Mar 27, 2006
  2. DaveInSidney
    Replies:
    0
    Views:
    399
    DaveInSidney
    May 9, 2005
  3. pabbu
    Replies:
    8
    Views:
    707
    Marc Boyer
    Nov 7, 2005
  4. Shravani
    Replies:
    8
    Views:
    779
    Bartc
    Mar 16, 2008
  5. Replies:
    28
    Views:
    1,142
Loading...

Share This Page