Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 7th, 2008, 10:22 AM
Authorized User
 
Join Date: Jan 2008
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default Redirect

HI

I am tring to redirect the user on the pageload event but the problem is it doesnt redirect:




Thanks
Sheraz

Code:

<%@ OutputCache Location="None" VaryByParam="none" %>
<%@ register TagPrefix="sc" Namespace="Sitecore.Web.UI.HtmlControls" Assembly="Sitecore.Kernel" %>
<%@ Page language="c#" EnableViewState="false" EnableViewStateMac="false" AutoEventWireup="false" Inherits="SitecoreClient.Page.NotFound" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >



<script runat =server >

    public void Page_Load(object sender, EventArgs e)
    {
        Response.Redirect("http://www.abc.com");
        Response.StatusCode=404;
    }
</script>






<html>
  <head>
    <title>Document not found</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio 7.0">
    <meta name="CODE_LANGUAGE" content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <link href="/sitecore/no.css" rel="stylesheet" type="text/css" >
  </head>
  <body>
    <table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
      <tr>
        <td class="scTop">
          <img src="/sitecore/images/blank.gif" alt="" border="0" width="1" height="1" />
        </td>
      </tr>

      <tr>
        <td class="scBody" align="center" height="599">
          <div style="width:600" align="left">

            <div class="scHeadline">The requested document was not found.</div>
            <br>
            <div>
              <b>Description:</b> The resource you are looking for (or one of its 
              dependencies) could have been removed, had its name changed, or is temporarily 
              unavailable. Please review the following URL and make sure that it is spelled 
              correctly.
            </div>
            <br>
            <div>
              <b>Requested URL:</b> &nbsp;<asp:placeholder id="url" runat="server" />
            </div>
            <br>
            <div>
              <b>User name:</b> &nbsp;<asp:placeholder id="c_user" runat="server" />
            </div>
            <br>
            <div>
              <b>Further information:</b><br>
              <br>
              <div style="PADDING-LEFT:32px">
                <asp:placeholder id="info" runat="server" />
              </div>
            </div>
            <br>
            <br>
            <br>
            <br>
            <div class="scTasks">Pick a task...</div>
            <br>
            <div>
              <asp:placeholder id="options" runat="server" />
            </div>
          </div>

        </td>
      </tr>

      <tr>
        <td class="scBottom" align="right" valign="bottom">
          <asp:placeholder id="version" runat="server" />
        </td>
      </tr>
    </table>
  </body>
</html>
 
Old February 9th, 2008, 08:14 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Your page directive does not seem valid. Did you copy this from a VB page or one with Code Behind?

Your method Page_Load doesn't fire because you don't set up a handler for the Page's Load event. You can do this programmatically, or let the run-time handle it:

<%@ Page language="c#" EnableViewState="false" EnableViewStateMac="false" AutoEventWireup="true" %>

With this highlighted option set to true, the run-time will hook up the Page_Load handler for you automatically.

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirect to Email jbedson ASP.NET 1.0 and 1.1 Basics 5 March 13th, 2007 05:14 PM
response.redirect sarah lee ASP.NET 1.0 and 1.1 Basics 1 October 27th, 2006 08:57 AM
No Access Redirect phungleon HTML Code Clinic 2 March 23rd, 2006 12:23 PM
URL Redirect Help david29118 Classic ASP Basics 3 April 3rd, 2005 06:09 PM
Redirect To New Page Ben Horne Flash (all versions) 2 March 26th, 2004 04:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.