473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

I need code for conditioned-redirection please

Hi,

I want an asp.net code for redirection:

I have multiple domains pointing to one page , let's call it page0.aspx

I want to put a code in page0.aspx so

when domain1 opens page0.aspx it redirects it to page1.aspx
when domain2 opens page0.aspx it redirects it to page2.aspx
.... etc

Is there a code for that?

Thank you.
Nov 17 '05 #1
3 1367
Hi,

Use the UrlReferrer property of the HttpRequest class. Say something
like this:

switch case(Request.UrlReferrer.ToString())
{
case "http://www.domain1.com/SomePage.aspx":
Response.Redirect("page1.aspx");
break;

case "http://www.domain2.com/SomePage.aspx":
Response.Redirect("page2.aspx");
break;
}

This code has some loop holes as in
"http://www.domain2.com/SomePage.aspx" might not be the exact string
returned by the UrlReferrer property, and you might have to use some
string handling like IndexOf() etc., but you get the basic idea, I
suppose.
Hope that helps.
Regards,
Sathyaish


Bishoy George wrote:
Hi,

I want an asp.net code for redirection:

I have multiple domains pointing to one page , let's call it page0.aspx

I want to put a code in page0.aspx so

when domain1 opens page0.aspx it redirects it to page1.aspx
when domain2 opens page0.aspx it redirects it to page2.aspx
... etc

Is there a code for that?

Thank you.


Nov 17 '05 #2
I received that error:
Server Error in '/IndexPage' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:
Line 17: {
Line 18: // Put user code to initialize the page here
Line 19: switch (Request.UrlReferrer.ToString())
Line 20: {
Line 21: case "http://domain.com/index.aspx":
Source File: e:\web sites\local host\indexpage\index.aspx.cs Line: 19

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
IndexPage.index.Page_Load(Object sender, EventArgs e) in e:\web
sites\local host\indexpage\index.aspx.cs:19
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750

--------------------------------------------------------------------------------

Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032

-------------------------------------------------------------------------------------------------------------------------------------------------------
using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

namespace IndexPage

{

public class index : System.Web.UI.Page

{

private void Page_Load(object sender, System.EventArgs e)

{

// Put user code to initialize the page here

switch (Request.UrlReferrer.ToString())

{

case "http://domain.com/index.aspx":

Response.Redirect("http://forum.domain.com");

break;

case "http://www.domain.com/index.aspx":

Response.Redirect("http://forum.domain.com");

break;

case "http://www.domain2.com/SomePage.aspx":

Response.Redirect("page2.aspx");

break;

}

}

#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.Load += new System.EventHandler(this.Page_Load);

}

#endregion

}

}

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Original Message ---
"Sathyaish" <sa*******@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi,

Use the UrlReferrer property of the HttpRequest class. Say something
like this:

switch case(Request.UrlReferrer.ToString())
{
case "http://www.domain1.com/SomePage.aspx":
Response.Redirect("page1.aspx");
break;

case "http://www.domain2.com/SomePage.aspx":
Response.Redirect("page2.aspx");
break;
}

This code has some loop holes as in
"http://www.domain2.com/SomePage.aspx" might not be the exact string
returned by the UrlReferrer property, and you might have to use some
string handling like IndexOf() etc., but you get the basic idea, I
suppose.
Hope that helps.
Regards,
Sathyaish


Bishoy George wrote:
Hi,

I want an asp.net code for redirection:

I have multiple domains pointing to one page , let's call it page0.aspx

I want to put a code in page0.aspx so

when domain1 opens page0.aspx it redirects it to page1.aspx
when domain2 opens page0.aspx it redirects it to page2.aspx
... etc

Is there a code for that?

Thank you.

Nov 17 '05 #3
You either have a firewall or some spyware detection software that is
stripping off the UrlReferrer from the Request buffer. This is a
commonly noted problem.

Look here for one possible workaround.

http://dotnet247.com/247reference/msgs/22/111827.aspx

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
10
by: Jeff Wagner | last post by:
I am in the process of learning Python (obsessively so). I've been through a few tutorials and read a Python book that was lent to me. I am now trying to put what I've learned to use by rewriting...
10
by: Beach Potato | last post by:
Dear Y'all: I'm about to start porting a big old project written in anscient version of Delphi to something more stable, robust, supportable and maybe even portable. Since I haven't seriously...
15
by: drdoubt | last post by:
using namespace std In my C++ program, even after applying , I need to use the std namespace with the scope resolution operator, like, std::cout, std::vector. This I found a little bit...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
1
by: mr_ocp | last post by:
Hi friends I need routines to create an excel file with worksheets for each customer and a text file as well for each customer, first worksheet would be a "Summary Report", here is the code that...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
18
by: joshc | last post by:
I've got two bits of code that I would like some more experienced folks to check for conformance to the Standard. I've tried my best to read the standard and search around and I think and hope this...
135
by: Xah Lee | last post by:
Tabs versus Spaces in Source Code Xah Lee, 2006-05-13 In coding a computer program, there's often the choices of tabs or spaces for code indentation. There is a large amount of confusion about...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.