John Kalberer
John Kalberer

Reputation: 5800

IIS7 URL rewrite + subdomain + ASP.Net MVC2

So I am working on a project with multiple areas and we would like to configure IIS to rewrite our requests to make the urls nicer. I have been messing around with the URL rewrite module all day and I cannot get the desired results.

Example:

I currently have a long url like 'http://register.example.com/Registration/Register/New' where Area = Registration, Controller = Register... I would like the user to request the site by 'http://register.example.com' and it hits the register controller which I have configured to default to the 'New' action. Because I gave the subdomain of register, IIS knows that it will be using the 'Registration' area.

The finish url would be something like 'http://register.example.com/Register/Finish'

Is this possible?

Thanks, John

Upvotes: 0

Views: 907

Answers (1)

Chase Florell
Chase Florell

Reputation: 47427

seeing as how you have marked MVC in your tags, you realize you can do this with a route.

    ''# Default Catch All MapRoute
    routes.MapRouteLowercase( _
        "Registration", _
        "{controller}/{action}/{step}", _
        New With {.controller = "Register", .action = "Registration", .step = "New"})

Then you just make a separate "website" in IIS to host the registration application.


PS... IMO sub-domains are overrated and often bad practice for the implementation you are describing. A sub-domain is used to describe a physical computer (IE your SQL server could be on sql.domain your web is on both domain and www.domain, and your email is on smtp.domain), it should not be used to separate sections of a single website. Also, many search engines index http:/subdomain.example.com separate from http://www.example.com, so your SEO values go way way down.

Upvotes: 1

Related Questions