Saturday, March 24, 2012

mapping hostname.com/username to a page

hi all,

I'm working on a project that will have user pages (you'll never guess that
its a social networking site ;-)

I'd like to map http://www.thehost.com/johndoe to
http://www.thehost.com/userpage.aspx?Id=2223
I know I can do this from IIS but it needs to be on the fly and handle an
arbitrary number of users. In the old days I'd use an ISAPI dll but there
must be a better tool now -- whats the right .net tool for this?

thanks,

johnThat's gonna be messy with IIS6. In IIS7 it's a piece of cake as for IIS6 i'd
suggest using this URL scheme:

thehost.com/johndoe.aspx - when using .aspx at the end you're able to dig
into it via (e.g.) global.asax in ASP.NET. If you want to use dynamic
folders, you'd have to missuse 404 Pages to make this work with IIS6, it's
not worth the effort.

Excellent post on URL Rewriting:
http://weblogs.asp.net/scottgu/arch...th-asp-net.aspx
--
More on ASP.NET and Silverlight on my blog: http://www.andreas-kraus.net/blog
"John Mott" wrote:

Quote:

Originally Posted by

hi all,
>
I'm working on a project that will have user pages (you'll never guess that
its a social networking site ;-)
>
I'd like to map http://www.thehost.com/johndoe to
http://www.thehost.com/userpage.aspx?Id=2223
>
I know I can do this from IIS but it needs to be on the fly and handle an
arbitrary number of users. In the old days I'd use an ISAPI dll but there
must be a better tool now -- whats the right .net tool for this?
>
thanks,
>
john
>
>
>


On Sep 17, 4:26 am, Andreas Kraus
<AndreasKr...@.discussions.microsoft.comwrote:

Quote:

Originally Posted by

That's gonna be messy with IIS6. In IIS7 it's a piece of cake as for IIS6 i'd
suggest using this URL scheme:
>
thehost.com/johndoe.aspx - when using .aspx at the end you're able to dig
into it via (e.g.) global.asax in ASP.NET. If you want to use dynamic
folders, you'd have to missuse 404 Pages to make this work with IIS6, it's
not worth the effort.
>
Excellent post on URL Rewriting:http://weblogs.asp.net/scottgu/arch...trick-url-rewri...
>
--
More on ASP.NET and Silverlight on my blog:http://www.andreas-kraus.net/blog
>
"John Mott" wrote:

Quote:

Originally Posted by

hi all,


>

Quote:

Originally Posted by

I'm working on a project that will have user pages (you'll never guess that
its a social networking site ;-)


>

Quote:

Originally Posted by

I'd like to maphttp://www.thehost.com/johndoe to
http://www.thehost.com/userpage.aspx?Id=2223


>

Quote:

Originally Posted by

I know I can do this from IIS but it needs to be on the fly and handle an
arbitrary number of users. In the old days I'd use an ISAPI dll but there
must be a better tool now -- whats the right .net tool for this?


>

Quote:

Originally Posted by

thanks,


>

Quote:

Originally Posted by

john


put some code into the Application_Error of your global.asax,
something like

Dim httpEx As HttpException = CType(ex, HttpException)
Dim httpCode As Integer = httpEx.GetHttpCode()
If httpCode = 404 Then
'go look up the URL and do a redirect to the appropriate page
End If
another way is to add the http 404 handler in web.config, and in the
processing page, u get URL Referrer.
URL Referrer doesn't work in some ways, but in my experience, with
hostname.com/username, it works everytime

On Sep 17, 4:49 am, densial <dens...@.gmail.comwrote:

Quote:

Originally Posted by

On Sep 17, 4:26 am, Andreas Kraus
>
>
>
>
>
<AndreasKr...@.discussions.microsoft.comwrote:

Quote:

Originally Posted by

That's gonna be messy with IIS6. In IIS7 it's a piece of cake as for IIS6 i'd
suggest using this URL scheme:


>

Quote:

Originally Posted by

thehost.com/johndoe.aspx - when using .aspx at the end you're able to dig
into it via (e.g.) global.asax in ASP.NET. If you want to use dynamic
folders, you'd have to missuse 404 Pages to make this work with IIS6, it's
not worth the effort.


>

Quote:

Originally Posted by

Excellent post on URL Rewriting:http://weblogs.asp.net/scottgu/arch...trick-url-rewri...


>

Quote:

Originally Posted by

--
More on ASP.NET and Silverlight on my blog:http://www.andreas-kraus.net/blog


>

Quote:

Originally Posted by

"John Mott" wrote:

Quote:

Originally Posted by

hi all,


>

Quote:

Originally Posted by

Quote:

Originally Posted by

I'm working on a project that will have user pages (you'll never guess that
its a social networking site ;-)


>

Quote:

Originally Posted by

Quote:

Originally Posted by

I'd like to maphttp://www.thehost.com/johndoeto
>http://www.thehost.com/userpage.aspx?Id=2223


>

Quote:

Originally Posted by

Quote:

Originally Posted by

I know I can do this from IIS but it needs to be on the fly and handle an
arbitrary number of users. In the old days I'd use an ISAPI dll but there
must be a better tool now -- whats the right .net tool for this?


>

Quote:

Originally Posted by

Quote:

Originally Posted by

thanks,


>

Quote:

Originally Posted by

Quote:

Originally Posted by

john


>
put some code into the Application_Error of your global.asax,
something like
>
Dim httpEx As HttpException = CType(ex, HttpException)
Dim httpCode As Integer = httpEx.GetHttpCode()
If httpCode = 404 Then
'go look up the URL and do a redirect to the appropriate page
End If- Hide quoted text -
>
- Show quoted text -


Thanks! I'm guessing that you have to use either relative paths (./) or
complete (http://) paths for images, stylesheets etc.?

john

"Nick Chan" <zzzxtreme@.yahoo.comwrote in message
news:1189998647.485348.42400@.57g2000hsv.googlegrou ps.com...

Quote:

Originally Posted by

another way is to add the http 404 handler in web.config, and in the
processing page, u get URL Referrer.
URL Referrer doesn't work in some ways, but in my experience, with
hostname.com/username, it works everytime
>
On Sep 17, 4:49 am, densial <dens...@.gmail.comwrote:

Quote:

Originally Posted by

>On Sep 17, 4:26 am, Andreas Kraus
>>
>>
>>
>>
>>
><AndreasKr...@.discussions.microsoft.comwrote:

Quote:

Originally Posted by

That's gonna be messy with IIS6. In IIS7 it's a piece of cake as for
IIS6 i'd
suggest using this URL scheme:


>>

Quote:

Originally Posted by

thehost.com/johndoe.aspx - when using .aspx at the end you're able to
dig
into it via (e.g.) global.asax in ASP.NET. If you want to use dynamic
folders, you'd have to missuse 404 Pages to make this work with IIS6,
it's
not worth the effort.


>>

Quote:

Originally Posted by

Excellent post on URL
Rewriting:http://weblogs.asp.net/scottgu/arch...trick-url-rewri...


>>

Quote:

Originally Posted by

--
More on ASP.NET and Silverlight on my
blog:http://www.andreas-kraus.net/blog


>>

Quote:

Originally Posted by

"John Mott" wrote:
hi all,


>>

Quote:

Originally Posted by

I'm working on a project that will have user pages (you'll never
guess that
its a social networking site ;-)


>>

Quote:

Originally Posted by

I'd like to maphttp://www.thehost.com/johndoeto
>http://www.thehost.com/userpage.aspx?Id=2223


>>

Quote:

Originally Posted by

I know I can do this from IIS but it needs to be on the fly and
handle an
arbitrary number of users. In the old days I'd use an ISAPI dll but
there
must be a better tool now -- whats the right .net tool for this?


>>

Quote:

Originally Posted by

thanks,


>>

Quote:

Originally Posted by

john


>>
>put some code into the Application_Error of your global.asax,
>something like
>>
>Dim httpEx As HttpException = CType(ex, HttpException)
>Dim httpCode As Integer = httpEx.GetHttpCode()
>If httpCode = 404 Then
> 'go look up the URL and do a redirect to the appropriate page
>End If- Hide quoted text -
>>
>- Show quoted text -


>
>

0 comments:

Post a Comment