Home  /  Questions  /  Question



256   99.6
Sep 20, 2010


Question about redirecting user based on the input


Hi,

I am working on an ASP.NET 3.5 web application where I need to redirect the user based in certain condition. I am currently checking the path and if it contains appropriate page say "TestPage.aspx" then generating the path using string.Format method. The code is somewhat below
if(string.Compare(path,"TestPage.aspx") == 0)
{
     return string.Format(some code here...);
}
else if(string.Compare(path,"TestPage1.aspx") == 0)
{
     return string.Format(another code here...);
}
Can I apply any pattern here so that there are less if-else condition and hard coding of the pages while comparison is removed?

Any help with this regard will be greatly appreciated.

Thanks,