0

I have a task which is to create an xml file with basically these elements:-

incoming request = sites/suppliers(.*?) should redirect to http://home.company/sites/sup$1

I'll read this xml file in Global.asax Application_BeginRequest event. Get the incoming request and check the xml file and do any redirection if necessary.

Could you guys please help me by giving the code in CSharp on how to acheive this.

Thanks In Advance.

Agamand The True
  • 832
  • 2
  • 10
  • 24

1 Answers1

1

Make XML Like this

<SiteRoot><Site URL="" KeyWord=""><SiteRoot>

Load this xml as XMLDocument object in Begin_Request, in method check the url or key words in the request, use Xmldoc.SelectSingleNode to select single url. Use Server.Transfer to redirect to the URL found using SelectSingleNode method

hungryMind
  • 6,931
  • 4
  • 29
  • 45
  • Thanks for your effort, but I think I need to use regular expression to check the incoming url to see that wether it match to any of the specified pattern in the XML lists. My XML file would contains sime thing like this http://www.somesite.com/sites/suppliers(.*?)http://www.newsite.com/sites/supplier$1 – Agamand The True Mar 09 '11 at 01:22
  • you can use contains or regular expression in xpath to find the url to redirect to. http://stackoverflow.com/questions/405060/can-i-use-a-regex-in-an-xpath-expression – hungryMind Mar 09 '11 at 14:39