tags:

views:

381

answers:

5

Some background

I'm currently working on a mobile site so I keep switching user agent all the time in Firefox with User Agent switcher (lovely addon). But when I go to the admin site it renders as WML, which makes Firefox all confused, so it tries to download it rather then showing the content. And this makes me frustrated (not falling down frustrated, but enough!).

What I want!

How can I make our admin site to ALWAYS send content as text/html instead of WML, regardless of request user-agent?

I have full control of the box. It's IIS 6.0.

A: 

This sounds like it's more to do with your admin system that the IIS box as the admin site is seeing the useragent as a mobile device and changing how it renders your request, from standard HTML over to .wml. You will need to change this in the app I believe.

TheAlbear
Hi, thanks for your answer. That was my first idea also. But since I didn't find such thing in the code I created a new WebbApplication and tried it with a Nokia n95 user-agent and got the content as wml. And if I try to browse SO with that user-agent I also get the response as text/vnd.wap.wml. which makes me think that asp.net use different contenttype for different user-agents.
Carl Bergquist
A: 

Configure the MIME type for the wml extension to text/html. You could also create a Custom HTTPHandler and point the script map for the extension to ASP.NET. Then, you could check for the conditions you and force the rendering any way you want it.

JP Alioto
I tried to change the Mime type on the webserver all thou I didn't seem to help. So I will try creating a custom HttpHandler
Carl Bergquist
A: 

You can override the server's behaviour with the ClientTarget property of the page.

In code:

Page.ClientTarget = "uplevel";

In the @ Page declaration:

<%@Page [...] clientTarget="uplevel" %>

Sadly, I don't think you can set this in the pages element of a web.config.

Zhaph - Ben Duguid
+1  A: 

As a workaround (if you fail to manage to do configure the app), you could install wmlbrowser add-on for firefox https://addons.mozilla.org/en-US/firefox/addon/62.

Senad Uka
Does not really answer my question, but helps me solve my problem :) cheerio!
Carl Bergquist
+2  A: 

If you want a no-code/no-aspx change, you can add a browser capabilities file into the folder App_Browsers directly under your application root (if the folder's not there, just create it). To disable WML, simply put a file named ForceHtml.browser (anything ending in .browser) containing the following XML:

<browsers>
  <browser refID="Default">
    <capabilities>
      <capability name="preferredRenderingMime" value="text/html" />
      <capability name="preferredRenderingType" value="html32" />
      <capability name="preferredImageMime" value="image/gif" />
      <capability name="tagwriter" value="System.Web.UI.HtmlTextWriter" />
    </capabilities>
    <controlAdapters markupTextWriterType="System.Web.UI.HtmlTextWriter" />
  </browser>
</browsers>
Ruben