Question

Currently in my project I have 2 master pages well call them Red and Blue for the color scheme they use. Depending on how a child page is called it will use either page. I have about 40 child pages completed.

I now have a need to pass a global variable (Request.ServerVariables["SERVER_NAME"]) down to my child pages so they know what server they are on by the host header.

Since my child pages dynamically use either the Red or Blue Master Page, the class namespace for each one needs to be the same. This causes a conflict at compile time since .net can't differentiate between the two.

My first try was setting this in a site library I'm using but the HTTP Request variables are out of scope of the cs file and DNS name doesn't work because they are on the same IIS instance.

Option 1 is to add a Master Page on top of Red and Blue, but then I'm not sure how to handle The Red and Blue Page's CSS, and controls. (In R and B there are 3 content Tags Head, Title, and Form). Then there is the issue of how to get the contents of the Top level Master Variable to the Child aspx page.

Option 2 is putting the Data MasterPage Under the Red and Blue, but then I don't know how to tell the Child page which top level page to use (currently selected by: if (Querystring !=null)

The end result is this:

  • The User opens Child.aspx from server1.ourservers.loc
  • The Red Master is used to render the page
  • "server1" is retrieved from a master page and child.aspx posts data to WebService A

or

  • The User opens Child.aspx from server2.ourservers.loc
  • The Blue Master is used to render the page
  • "server2" is retrieved from a master page and child.aspx posts data to WebService B

Under no circumstance may server1 post to WebService B or server2 post to WebService A

Thoughts? Is there a simpler way that this?

Was it helpful?

Solution

This turned out to be completely the wrong direction. I needed to use HttpContext.Current.Request.ServerVariables["SERVER_NAME"] in my class file to get the data I wanted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top