473,411 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

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



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

Mar 21 '07 #1
5 1794
char[] x = {'/'}
string[] url = Request.RawUrl.Split(x);
string CompanyName = url[url.Length-2]

The above code should work. Good luck.

On Mar 21, 12:28 pm, Jay Pondy <jpo...@bellsouth.netwrote:
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

Mar 21 '07 #2
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
On 21 Mar 2007 12:39:59 -0700, "jobo" <jo*****@gmail.comwrote:
>char[] x = {'/'}
string[] url = Request.RawUrl.Split(x);
string CompanyName = url[url.Length-2]

The above code should work. Good luck.

On Mar 21, 12:28 pm, Jay Pondy <jpo...@bellsouth.netwrote:
>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
Mar 21 '07 #3
On Mar 21, 8:46 pm, Jay Pondy <jpo...@bellsouth.netwrote:
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.

Mar 21 '07 #4

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?

On 21 Mar 2007 12:52:07 -0700, "Alexey Smirnov" <al************@gmail.com>
wrote:
>On Mar 21, 8:46 pm, Jay Pondy <jpo...@bellsouth.netwrote:
>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.
Mar 21 '07 #5
It sounds to me like URL Rewriting would probably do the trick for you.
I just saw Scott Guthrie give a great presentation on the latest and
greatest ways to do this with IIS7.
Here's his blog post that describes that technique and alternatives:
http://weblogs.asp.net/scottgu/archi...h-asp-net.aspx

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Jay Pondy" <jp****@bellsouth.netwrote in message
news:ig********************************@4ax.com...
>

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
Mar 22 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael Hogan | last post by:
I want to pars a playlist file for three different varibles, so I can save them as mp3 files. I am using: strTEMPURL = GetUrlSource(Text1.Text) to put the entire .pls file into a strTEMPURL...
9
by: RiGGa | last post by:
Hi, I want to parse a web page in Python and have it write certain values out to a mysql database. I really dont know where to start with parsing the html code ( I can work out the database...
5
by: Andrew Lighten | last post by:
Hi all; I'm really struggling to get C# to do the right thing when parsing non-decimal strings as numbers. What I really want to be able to do is take a string containing an integer in any valid...
10
by: Mel | last post by:
i have a need to access variables from outside of my applications. i need to parse the compiler created symbol tables and store them so that i can reference them later. these include C++ object...
5
by: Steven Berkovitz | last post by:
I am trying (without any luck) to find a way to parse a string and output its processed results. ie: string text = "This is text from a CMS tool <asp:Label runat=\"server\" id=\"test\"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.