server-side timer vs. meta refresh

Discussion in 'ASP .Net' started by Jim Hammond, Oct 24, 2003.

  1. Jim Hammond

    Jim Hammond Guest

    After much effort, it doesn't seem possible to redirect the user to a new
    page after 10 seconds by using a server-side timer. I am now using the
    following meta statement to accomplish the same thing:

    <META HTTP-EQUIV="refresh" content="10;URL=Form_Welcome.aspx">

    This seems to work fine, but I now have three concerns because I thought it
    was supposed to be possible to do everything in C#.
    1. Note that Visual Studio lets the developer drag and drop a timer onto the
    web form, which now seems like a pointless feature.
    2. Will server-side code know how to handle the redirection caused by the
    META tag as well as if I had used C#?
    3. I manually edited the .aspx file, which means that my code is not as
    clean and is harder to maintain.

    Jim
     
    Jim Hammond, Oct 24, 2003
    #1
    1. Advertising

  2. Jim Hammond

    Alvin Bruney Guest

    Well it is possible, but this can be easier and cleanly accomplished on the
    client side since you are implying that after some event of time period on
    the client, it should redirect itself somewhere else. This is not really a
    server side concern, but rather a client side issue, hence the solution
    should probably be a client side solution.

    It isn't pointless. It just doesn't work cleanly in your situation. Here's
    one scenario where it comes in. If you want clean up on the server after a
    scheduled amount of time, a timer is a very good avenue. Notice, this would
    be a server side solution not requiring client-side interference.

    The redirection is handled just as if it were server transfer or redirect.

    :-( that's the disadvantage of using the inline code method.

    --


    -----------
    Got TidBits?
    Get it here: www.networkip.net/tidbits
    "Jim Hammond" <> wrote in message
    news:...
    > After much effort, it doesn't seem possible to redirect the user to a new
    > page after 10 seconds by using a server-side timer. I am now using the
    > following meta statement to accomplish the same thing:
    >
    > <META HTTP-EQUIV="refresh" content="10;URL=Form_Welcome.aspx">
    >
    > This seems to work fine, but I now have three concerns because I thought

    it
    > was supposed to be possible to do everything in C#.
    > 1. Note that Visual Studio lets the developer drag and drop a timer onto

    the
    > web form, which now seems like a pointless feature.
    > 2. Will server-side code know how to handle the redirection caused by the
    > META tag as well as if I had used C#?
    > 3. I manually edited the .aspx file, which means that my code is not as
    > clean and is harder to maintain.
    >
    > Jim
    >
    >
     
    Alvin Bruney, Oct 25, 2003
    #2
    1. Advertising

  3. Jim Hammond

    mikeb Guest

    Jim Hammond wrote:

    > After much effort, it doesn't seem possible to redirect the user to a new
    > page after 10 seconds by using a server-side timer. I am now using the
    > following meta statement to accomplish the same thing:
    >
    > <META HTTP-EQUIV="refresh" content="10;URL=Form_Welcome.aspx">
    >
    > This seems to work fine, but I now have three concerns because I thought it
    > was supposed to be possible to do everything in C#.
    > 1. Note that Visual Studio lets the developer drag and drop a timer onto the
    > web form, which now seems like a pointless feature.


    There are uses for timers on the server-side. It doesn't happen to fit
    our application well, however.

    > 2. Will server-side code know how to handle the redirection caused by the
    > META tag as well as if I had used C#?


    I'm not sure what you're asking... The server doesn't really know
    anything about the redirection. The browser simply makes a request to
    the URL specified in meta tag. If the URL is pointing back to the same
    server, then the server will be aware of it. If the URL points
    somewhere else, then the server will never know.

    > 3. I manually edited the .aspx file, which means that my code is not as
    > clean and is harder to maintain.


    You can handle the meta tag using C# code-behind techniques by giving
    the meta tag an id attribute and a runat="server" attribute. Then in
    the code-behind, declare an HtmlGenericControl in your Page class with
    the same name as the meta tag's id attribute.

    Now you can add the HTTP-EQUIV and content attributes using C# code.
    This will let you dynamically control how long the refresh time is, and
    where the redirection will go. You could also remove the meta tag
    altogether (if you don't want the redirection) by setting the Visible
    property to false.

    Finally you can use C# to inject Javascript into the page (using
    RegisterClientScriptBlock() and/or RegisterStartupScript()) which would
    perform the refresh, if you'd rather not use the meta tag - this would
    give you additional possibilities for handling the redirection.

    >
    > Jim
    >
    >


    Controlling the client in a disconnected web browser model is
    significantly different from controlling the client in a Windows
    application or dedicated, connected client application model.

    --
    mikeb
     
    mikeb, Oct 25, 2003
    #3
  4. Jim Hammond

    David Guest

    In article <>, mikeb wrote:
    > Jim Hammond wrote:
    >
    >
    >> 3. I manually edited the .aspx file, which means that my code is not as
    >> clean and is harder to maintain.

    >
    > You can handle the meta tag using C# code-behind techniques by giving
    > the meta tag an id attribute and a runat="server" attribute. Then in
    > the code-behind, declare an HtmlGenericControl in your Page class with
    > the same name as the meta tag's id attribute.


    Or in this case, since it's an HTTP-EQUIV, you can just add the header
    directly and forget about the meta tags altogether.

    Response.AppendHeader("Refresh", "3; URL=/some/url/here")


    Although, in the general case, I don't really see manually editing the
    ..aspx file as A Bad Thing.

    --
    David
    dfoster at
    hotpop dot com
     
    David, Oct 25, 2003
    #4
  5. Jim Hammond

    mikeb Guest

    David wrote:

    > In article <>, mikeb wrote:
    >
    >>Jim Hammond wrote:
    >>
    >>
    >>
    >>>3. I manually edited the .aspx file, which means that my code is not as
    >>>clean and is harder to maintain.

    >>
    >>You can handle the meta tag using C# code-behind techniques by giving
    >>the meta tag an id attribute and a runat="server" attribute. Then in
    >>the code-behind, declare an HtmlGenericControl in your Page class with
    >>the same name as the meta tag's id attribute.

    >
    >
    > Or in this case, since it's an HTTP-EQUIV, you can just add the header
    > directly and forget about the meta tags altogether.
    >
    > Response.AppendHeader("Refresh", "3; URL=/some/url/here")
    >
    >
    > Although, in the general case, I don't really see manually editing the
    > .aspx file as A Bad Thing.
    >


    Good call.

    I'd agree that editing the aspx file is not necessarily a bad thing - in
    fact, it would be my preference if the refresh should be there
    unconditionally.

    The Response.AddHeader() approach would be the best for dynamically
    adding the redirection.

    --
    mikeb
     
    mikeb, Oct 27, 2003
    #5
    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. Replies:
    1
    Views:
    1,656
    Steve C. Orr [MVP, MCSD]
    Feb 22, 2005
  2. George Durzi
    Replies:
    3
    Views:
    4,848
    George Durzi
    Apr 28, 2005
  3. Nym Pseudo

    META NAME and META HTTP-EQUIV

    Nym Pseudo, Sep 26, 2003, in forum: HTML
    Replies:
    1
    Views:
    590
    =?iso-8859-1?Q?brucie?=
    Sep 26, 2003
  4. John Davis

    refresh client side time and server side time

    John Davis, Aug 19, 2003, in forum: ASP General
    Replies:
    1
    Views:
    163
    Adrian Forbes - MVP
    Aug 19, 2003
  5. Duane Johnson

    Meta methods to govern meta data?

    Duane Johnson, Oct 25, 2005, in forum: Ruby
    Replies:
    6
    Views:
    263
    Adam Sanderson
    Oct 28, 2005
Loading...

Share This Page