URL Parsing - Can you point me in the right direction?

J

Jay Pondy

Given these two virtual paths

http://mysite.com/ABCCompany/SomePage.aspx
http://mysite.com/XYZCompany/SomePage.aspx

Is there any way in ASP.Net 2.0 to parse out the 'ABCCompany' and 'XYZCompany'
strings from the URLs listed and have SomePage.aspx be common to both paths
WITHOUT upsetting how ASP.Net processes SomePage.aspx.

The idea being to make it look like each company has their own set of pages when
in reality they are all the same set of pages.

We are looking for a simple way to make a distinction about which company is
using the web site without asking them to pick their company during a log in. We
want to parse the company out of the URL before ASP.Net gets hold of the page.

I'm not sure if this would be called URL re-writing or what so I just need a
shove in the right direction or maybe there is a better way of doing this.

Thanks
 
J

jobo

char[] x = {'/'}
string[] url = Request.RawUrl.Split(x);
string CompanyName = url[url.Length-2]

The above code should work. Good luck.
 
J

Jay Pondy

Thanks for the quick response jobo - your code will extract the Company from the
URL but it won't get ASP.Net to process the SomePage.aspx.

After doing some more research it appears that what I want to do is in fact
called URL re-writing and is covered in this article:

http://msdn2.microsoft.com/en-us/library/ms972974.aspx


char[] x = {'/'}
string[] url = Request.RawUrl.Split(x);
string CompanyName = url[url.Length-2]

The above code should work. Good luck.

Given these two virtual paths

http://mysite.com/ABCCompany/SomePage.aspxhttp://mysite.com/XYZCompany/SomePage.aspx

Is there any way in ASP.Net 2.0 to parse out the 'ABCCompany' and 'XYZCompany'
strings from the URLs listed and have SomePage.aspx be common to both paths
WITHOUT upsetting how ASP.Net processes SomePage.aspx.

The idea being to make it look like each company has their own set of pages when
in reality they are all the same set of pages.

We are looking for a simple way to make a distinction about which company is
using the web site without asking them to pick their company during a log in. We
want to parse the company out of the URL before ASP.Net gets hold of the page.

I'm not sure if this would be called URL re-writing or what so I just need a
shove in the right direction or maybe there is a better way of doing this.

Thanks
 
G

Guest

Thanks for the quick response jobo - your code will extract the Company from the
URL but it won't get ASP.Net to process the SomePage.aspx.

After doing some more research it appears that what I want to do is in fact
called URL re-writing and is covered in this article:

I think, you can also have two virtual directories 'ABCCompany' and
'XYZCompany' in IIS that points to a real directory with
SomePage.aspx, etc.
 
J

Jay Pondy

Yes - two virtual directories pointing to the same real directory would work.

Trouble is this application will be used with 100+ companies so managing those
virtual directories would probably get out of hand pretty quick.

As a follow up to my original post I was able to get my HTTPModule in the
pipeline and wired up to the AuthorizeRequest event where I placed
EventLog.WriteEntry for debugging.

I was surprised to find that the AuthorizeRequest Event fired numerouse times as
the page went from Login.aspx to Default.aspx. I am using a Master Page with 3
images and I am guessing that each AuthorizeRequest event that is firing must be
for the individual pieces that make up the entire page?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top