Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 January 31st, 2005, 05:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default Question re: Acquiring HTTP_REFERER

In my web.config file I am redirecting all errors encountered in any ASPX page in my application to a ERROR.aspx page. I would like to be able to capture the HTTP_REFERER that brings my user to this ERROR.aspx page. I also have a RETRY button on this ERROR.aspx page that I would like to assign the value of that HTTP_REFERER and have the user try again. I have tried using the following C# code in my code behind page to get this effect but to no avail:

namespace ThrOrg.errorhandle
{
/// <summary>
/// Summary description for errorhandle.
/// </summary>
///

public class errorhandle : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button retryButton;
protected System.Web.UI.WebControls.Panel errorPanel;
private string strHTTP;

private void Page_Load(object sender, System.EventArgs e)
{
strHTTP = Request.Querystring.Get("aspxerrorpath").ToString( );
Response.Write(strHTTP);
SqlConnection dbConnection;
try
{
dbConnection = Thr.Utilities.Database.GetDBConnection();
}
catch (Exception exc)
{
Literal content = new Literal();
content.Text = "Connection to database server not available at this time. Please try again later.<br><br><br>";
this.errorPanel.Controls.Add(content);
this.errorPanel.Visible = true;
return;
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.retryButton.Click += new System.EventHandler(this.retryButton_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void retryButton_Click(object sender, System.EventArgs e)
{
   Response.Redirect(strHTTP);
}
}
}

Any help or direction that anyone has time to give would be appreciated. Thanks.
 
Old February 1st, 2005, 04:54 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Hi,
    You can use the asperrorpath querystring value to get back to the page.When .NET redirects to the custom error page it appends one querystring also with it named asperrorpath which contains the URL of the requested page.



 
Old February 1st, 2005, 08:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default

Santhi,

Thanks for the reply. Finally got a little farther using the code above but my problem is appending the "http://SERVERNAME" + strHTTP in my response.redirect without hard coding it in:

http://localhost/errorhandle/errorha...ners_Dues.aspx

I am stuck trying this code but when I try to write it out I get nothing:

private void retryButton_Click(object sender, System.EventArgs e)
{
    Response.Redirect(strHTTP);
}

Any help would be appreciated. THANKS!!
 
Old February 1st, 2005, 11:19 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Why you are appending the "http://servername" ..You can give directly the path from aspxerrorpath to Response.Redirect .it will work.






Similar Threads
Thread Thread Starter Forum Replies Last Post
<%=Request.ServerVariables("HTTP_REFERER")%> t400 Classic ASP Basics 0 June 30th, 2006 07:26 AM
HTTP_REFERER p2pMember Classic ASP Basics 5 March 14th, 2006 10:54 PM
htaccess: restrict by http_referer AND domain TrishD Linux 3 December 5th, 2004 03:38 PM
HTTP_REFERER Tester Sometimes Redirects OK Visitor markw707 Classic ASP Basics 4 August 21st, 2003 11:41 PM





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