« Previous Next »

Answered Thread: Prevent automatic content type switching to text/vnd.wap.wml of *.aspx files

Last post 06-02-2010 6:52 PM by Nalle_j. 2 replies.

 

RSS

Page 1 of 1 (3 items)

Sort Posts:

  • 01-28-2010, 2:56 PM

    • Ralias
    • Not Ranked
    • Joined on 01-28-2010, 5:36 PM
    • Posts 4

    Prevent automatic content type switching to text/vnd.wap.wml of *.aspx files

    This post is related to http://forums.iis.net/p/1151402/1878121.aspx and http://forums.iis.net/p/1151147/1877070.aspx. I was able to reproduce the behaviour that is described there. The scenario is quiet simple. Create a simple "Hello World" asp.net page that is cachable like that:

    <%@ OutputCache Duration="360" VaryByParam="none" Location="Any"%>
    <html>
    <head><title>Test</title></head>
    <body>
    <p>Hello World</p>
    </body>
    </html>

    Now use a client that accepts the content type text/vnd.wap.wml only to request the page. IIS delivers the page with the content-type header set to the requested type and puts the page in the cache. While the page is cached any subsequent request will return the same header and content. Users who access the page get a download prompt until the cache expired.

     The solution/workaround for the problem is quiet easy: Advise the cache to var by the "content-type" header by changing the header like that:

    <%@ OutputCache Duration="360" VaryByParam="none" VaryByHeader="Content-Type" %>

    However my preferred solution would be to prevent the IIS to deliver asp.NET files as text/vnd.wap.wml as long as I don't code it by myself. Does anyone know if there is a configuration setting for that?

    P.S.: The following C# code simulates a device that accepts text/vnd.wap.wml only:

    using System;
    using System.IO;
    using System.Net;

    class Program
    {
     static void Main( string[] args )
     {
      string url = "http://webserver/test.aspx";
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create( url );
      request.Method = "GET";
      request.UserAgent = "Test";
      request.Accept = "text/vnd.wap.wml";

      HttpWebResponse response = (HttpWebResponse)request.GetResponse();
      Console.WriteLine( response.Headers.ToString() );
      TextReader responseReader = new StreamReader( response.GetResponseStream() );
      string content = responseReader.ReadToEnd();
      Console.WriteLine( content );

      Console.ReadKey();
     }
    }

     

  • 02-02-2010, 1:43 AM In reply to

    Answered Re: Prevent automatic content type switching to text/vnd.wap.wml of *.aspx files

    Hi,

    You can try add a cache rule to configure IIS cache different versions of a file based on http headers(IIS Manager->High-light your site on the connection pane->Click the Output Caching icon on the home pane->Click Add on the Actions pane->Type the file name extension->Selected user-mode caching->Click Advanced). Thanks.

     

    Leo Tang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • 06-02-2010, 6:52 PM In reply to

    • Nalle_j
    • Not Ranked
    • Joined on 09-23-2005, 5:17 AM
    • Posts 1

    Re: Prevent automatic content type switching to text/vnd.wap.wml of *.aspx files

     I had the same problem, but varying by "Content-Type" did not solve it for me. I had to vary by "Accept" in order to get rid of the problem.

Page 1 of 1 (3 items)