views:

358

answers:

4

How do i do this in .NET? http://why.does.my.head.asplode.net/ I want to do something like ytmnd where each url is a different user generated page. I might need something as simple as pointing to a directory so dirname.mysite.com will redirect to http_public/userGenContent/dirname/

A: 

I suggest you use UrlRewritingNet. You may have to add a rule similar to this:

      <add virtualUrl="http://(.*).asplode.net/index.aspx"             
       rewriteUrlParameter="ExcludeFromClientQueryString"  
       destinationUrl="~/Users.aspx?username=$1" 
       ignoreCase="true" />

I cannot test this since I'm on a Linux machine right now, but it should work ;).

The WebMacheter
In case you don't know, ASP.NET runs on Linux too. http://www.mono-project.com/Mod_mono
ssg
A: 

The various UrlRewriting tools will help you once you have the request getting into ASP.NET, however before that happens you need to setup IIS to pass these requests to your app. This is simple enough if there's only one app on the server, but more difficult otherwise.

Check out http://msmvps.com/blogs/bernard/archive/2005/03/22/39218.aspx for some details on wildcard subdomains on IIS.

Alternatively use an IIS level rewriter like ISAPI Rewrite

Essentially search for IIS wildcard subdomain to find a wealth of approaches.

Richard Mason
A: 

Well, IIS7 has built url rewrite functionality. You can specify rules etc in web.config. But for IIS6 you need ISAPI dll that does the same for you. I've used IIRF and it works just fine.

hetu
+1  A: 

HAHA ...

I handled the Begin request event in global.aspx for this because my urls come from sql server.

Why are so many people sub domain crazy these days?

in Begin Request you can do something like this (not usre exactly because I aint got it in front of me right now) ...

request.rewriteurl( "new url" );

... this will take whatever the source url is and "redirect" without a redirect the response to a url you can use internally.

Wardy