1

I'm currently looking into url-rewriting and how it should be done right and hope you have some inputs here.

At the current stage of development only the kind of url-rewriting I'm interested in is adding facebook like behavior to businesses to which we provide services on our site, i.e. www.mysite.com/ShowBusinessInfo.aspx?id=1 should be rewritten to www.mysite.com/HostedBusinessName. - The idea is that when a business registers on our site they can choose whatever the last part of the url should be.

What would be the best way to support this feature? Custom IHttpModule, Global.asax (I'm afraid that this is too slow?), UrlRewriter.net/UrlRewriting.net or a completely different solution.

The site is developed in asp.net and runs on IIS 7.5.

2 Answers 2

0

I've actually done something like this before and this is the article I used as a resource: http://stweet.wordpress.com/2010/03/15/creating-a-new-website-programmatically-on-iis-using-asp-net/

This article will tell you how to programmically add a web site to your IIS using C#. Keep in mind that depending on how your IIS and DNS is setup, you may need to also modify your DNS server. You can find various scripts for doing this here: http://msdn.microsoft.com/en-us/library/ms682129%28VS.85%29.aspx

Hope this helps!

2
  • I don't know if this is useable as I don't think I can run the web application with admin-rights. Furthermore for the time being www.mysite.com/ShowBusinessInfo.aspx?id=1 is the only page to need this feature and the page only shows db stored information about the business.
    – Jaypeg
    Jul 7, 2010 at 17:00
  • If you don't have server admin rights, then your only option is URL rewriting. Check this site out: urlrewriter.net
    – Icemanind
    Jul 7, 2010 at 17:07
0

If you have fairly simply rewriting rules, I'd use an IHttpModule that attempts to match the URL's LocalPath property with a value in your DB, and then calls context.RewritePath(string).

If you have more complex stuff, then I'd start looking at UrlRewriting.NET or the routing options in ASP.NET.

2
  • The rules are fairly simple I guess, but there will probably be over 100 id's in need of rewriting. Do you have any link to routing options (I do not use asp.net MVC)
    – Jaypeg
    Jul 7, 2010 at 21:54
  • do you mean hundreds of pages that need rewriting? or that one page will have hundreds of different IDs used on it? if the latter, go w/ the HttpModule. Jul 8, 2010 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.