redirecting a page link and changing page text based on link
OK I am not sure if the question title is actually correct , newbie web developer here so bear with me.
This is an ASP.NET webiste running on IIS 6.0 So here is the problem: I have two pages called Page1 and Home you can navigate to both like so www.mysite.com/Page1.aspx, www.mysite.com/Home.aspxPage1 is now undergoing a lot changes so that it is going to end up looking a lot like Home except for some really small text changes. Also there are a number of emails in the wild with customers that link to Page1 and \ or Home
What I want is a solution that does the following
Create One page( say newhome.aspx) which displays the correct text based on the URL of the link that people clicked on to get here
Let existing links go to this new pa开发者_运维问答ge( and of course as per the above requirement the appropriate text would be displayed)
I guess they sort of are the same requirement , bottom line I want only one page and all legacy links to continue to work as in get redirected to this new page
Thanks
In order to make sure the old links still work you can either:
Keep the old pages there and use Response.Redirect() in the Page_Load methods, and pass some sort of query string parameter to tell the new page what text to show. For example:
Response.Redirect("~/newhome.aspx?oldUrl=" + Server.UrlEncode(Request.Url.ToString()));
Or use the ASP.NET routing system to create routes from the old URLs to the new page. Then inside the new page you get the url that the user used from Request.Url.
Then in the new page you can do something like this:
protected void Page_Load(object sender, EventArgs e)
{
string requestUrl = "";
. . .
if (requestUrl.ToString().EndsWith("Page1.aspx"))
label.Text = "foo";
else
label.Text = "bar";
}
You could just develop your new page and in the old page (OnLoad) event you could just do a Response.Redirect() to the new page?
精彩评论