Question

I have an .NET MVC 3, SQL Server application running on Azure. It has 2 web role instances and a single worker role instance.

We allow customers to insert an iFrame into their site that shows our content.

To get this content, we have a public page that accepts the companies unique identifier. For instance, StackOverflow would use 'http://myapplication.com/stack-overflow'. This would return a html page specific to the company.

We like the idea of mapping a CName record on the clients side directly to their content on our application. From what I understand we need to accept, in StackOverflow's case, 'stack-overflow.myapplication.com' find the extract the subdirectory and return the content at 'http://myapplication.com/stack-overflow'.

Can anyone shed some light on how this is done on Azure?

Was it helpful?

Solution

It would be the same for Azure and for any IIS deployed application. You just need to map all the custom sub-domains as CNAME to your cloudapp.net domain. Do not change anything in your service definition and/or configuration files. And withing your application, have a simple logic that would check for:

Request.Headers["host"]

This header will have the full host name (i.e. stack-overflow.myapplication.com). You can now parse the URL, extract the subdomain and map it to appropriate resource.

Another approach would be to use the URL rewrite module for IIS and build something similar to what I did with Apache Web Server and mod_rewrite (I think exactly what you need). I am not sure whether you can use my Apache rewrite rules 1:1 for IIS rewrite module, but it would be a good starting point. Note that now (since Azure SDK 1.3) URL Rewrite module is enabled by default in Azure full IIS).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top