Re: 301 redirect to new domain

Discussion in 'ASP .Net' started by Shan Plourde, Jul 23, 2004.

  1. Shan Plourde

    Shan Plourde Guest

    I think I remember having this problem. My solution was to select all of
    my source code, cut it to the clipboard, save the file, paste it back in
    from the clipboard, save, and then everything was ok...hope that helps
    Shan Plourde

    Ben wrote:

    >I'm trying to use this sample code on my default.aspx page:
    ><script runat="server">
    >private void Page_Load(object sender, System.EventArgs e)
    >{
    >Response.Status = "301 Moved Permanently";
    >Response.AddHeader("Location"," www.newsite.com/index.html");
    >}
    ></script>
    >
    >And I'm getting a end of statement expected on this line:
    >private void Page_Load(object sender, System.EventArgs e)
    >
    >I've seen the exact same code on several websites so I'm thinking I must be missing something obvious. Can anyone tell me what would cause this error?
    >
    >Thanks
    >
    >
    >
    >
    >
    >
     
    Shan Plourde, Jul 23, 2004
    #1
    1. Advertising

  2. Thanks Shan. I know how cutting and pasting sometimes does not work correctly. I double check and it was not the case this time.

    I'm adding the detailed compiler output:

    Microsoft (R) Visual Basic .NET Compiler version 7.10.3052.4
    for Microsoft (R) .NET Framework version 1.1.4322.573
    Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.

    E:\web\webserver\htdocs\redirect2.aspx(4) : error BC30205: End of statement expected.

    private void Page_Load(object sender, System.EventArgs e)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    E:\web\webserver\htdocs\redirect2.aspx(5) : error BC30035: Syntax error.

    {
    ~
    E:\web\webserver\htdocs\redirect2.aspx(6) : error BC30188: Declaration expected.

    Response.Status = "301 Moved Permanently";
    ~~~~~~~~
    E:\web\webserver\htdocs\redirect2.aspx(7) : error BC30188: Declaration expected.

    Response.AddHeader("Location"," www.newsite.com/index.html");
    ~~~~~~~~
    E:\web\webserver\htdocs\redirect2.aspx(8) : error BC30035: Syntax error.

    }
    ~
     
    =?Utf-8?B?QmVu?=, Jul 23, 2004
    #2
    1. Advertising

  3. Shan Plourde

    Shan Plourde Guest

    The only other thing that I can think of is that you need to ensure that
    c# is the default script processing language. You can set that in your
    web.config or in your <script tag:
    <script language="c#" runat="server">
    ....

    Also I generally use the protected visibility for page_load when I have
    page_load in an ascx file. I do this becuase I assume that the asp.net
    page processing design will not be able to run private events of child
    pages from parent pages...try those things and see what happens

    Ben wrote:

    >Thanks Shan. I know how cutting and pasting sometimes does not work correctly. I double check and it was not the case this time.
    >
    >I'm adding the detailed compiler output:
    >
    >Microsoft (R) Visual Basic .NET Compiler version 7.10.3052.4
    >for Microsoft (R) .NET Framework version 1.1.4322.573
    >Copyright (C) Microsoft Corporation 1987-2002. All rights reserved.
    >
    >E:\web\webserver\htdocs\redirect2.aspx(4) : error BC30205: End of statement expected.
    >
    >private void Page_Load(object sender, System.EventArgs e)
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    >E:\web\webserver\htdocs\redirect2.aspx(5) : error BC30035: Syntax error.
    >
    >{
    >~
    >E:\web\webserver\htdocs\redirect2.aspx(6) : error BC30188: Declaration expected.
    >
    >Response.Status = "301 Moved Permanently";
    >~~~~~~~~
    >E:\web\webserver\htdocs\redirect2.aspx(7) : error BC30188: Declaration expected.
    >
    >Response.AddHeader("Location"," www.newsite.com/index.html");
    >~~~~~~~~
    >E:\web\webserver\htdocs\redirect2.aspx(8) : error BC30035: Syntax error.
    >
    >}
    >~
    >
    >
    >
     
    Shan Plourde, Jul 23, 2004
    #3
    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. Luigi Donatello Asero

    Redirect 301

    Luigi Donatello Asero, Feb 23, 2006, in forum: HTML
    Replies:
    15
    Views:
    981
    Jonathan N. Little
    Feb 26, 2006
  2. JB
    Replies:
    6
    Views:
    417
    =?iso-8859-1?Q?Kim_Andr=E9_Aker=F8?=
    Nov 22, 2006
  3. frankmcma

    Undo 301 Redirect?...

    frankmcma, Apr 10, 2007, in forum: HTML
    Replies:
    3
    Views:
    9,664
    Jukka K. Korpela
    Apr 11, 2007
  4. Ross Culver

    301 Permanent Redirect

    Ross Culver, Aug 15, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    360
    Ross Culver
    Aug 15, 2007
  5. Eirik Eldorsen

    How to 301 redirect default.aspx to root

    Eirik Eldorsen, Nov 26, 2007, in forum: ASP .Net
    Replies:
    10
    Views:
    5,111
    ThatsIT.net.au
    Dec 22, 2007
Loading...

Share This Page