Using separate content for some pages on a different subdomain in ASP.NET web forms site

StackOverflow https://stackoverflow.com/questions/17327411

Pergunta

A bit of background: I've got a large ASP.NET Web Forms site (quite a lot of pages) which I have been asked to do a mobile friendly version for. I plan to do this on a separate subdomain. Most pages on the site will simply use a different master page and theme and keep the same content so that I don't need to maintain 2 separate copies of the site and I was planning on using a single IIS website with 2 hostnames and code the logic in the page base class to sort out the master page and theme. However, a small number of key pages will need a totally separate mobile friendly version writing with different HTML and I'm wondering the best way of dealing with this.

Ideally, I'd like to keep them in a subdirectory within the site that mirrors the main site, but for them to show up as the page with the original url. ie if I load m.domain.com/default.aspx then it should silently check to see if domain.com/m/default.aspx exists and use that instead. I don't want this to show up as a browser redirect - I want the server to do the work and I don't think Server.Transfer will work because when it posts back I think it will post back to itself at the URL in the folder. Is there some other way of redirecting the rendering of a page that will do what I want?

Foi útil?

Solução

I eneded up writing an HTTPModule to automatically redirect when appropriate

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top