Some features of Wap - programming

    Good afternoon, dear. I prefer to read topics in which not some abstract things are highlighted, but their specific application. That is why I want to share my experience gained in developing a wap page on our project.
    Our project is based on .Net architecture. Therefore, the entire server side will be in C #.


    Preamble


    One fine day on our project it was required to make a wap page. And make 2 of its options - html and wml. Since I hadn’t done such things before, everything was new. If I write obvious things - do not swear, please. This article is intended for those who do not constantly make up wap pages, but sometimes such a need arises.

    Bit of theory


    What is html explaining, I think, is not worth it :)
    But wml is worth a little stop. A few facts about this markup language:

    1. The page starts and ends with the <wml> tag
    2. All information is in tags <card>
    3. Page size no more than 4kb
    4. Does not support css
    5. Pictures are WBMP only, i.e. black and white

    More on wiki
    In fact, wml is no longer used anywhere. The kingdom of xhtml has come :)

    Practice. Client part


    The first thing that I understood when layouting wap pages was without a doctype anywhere.
    Secondly, some phones display the page only with a fully valid layout.

    How to make the phone display your page, already made up for small screens?
    It needs to be validated!
    And for this you need the xml definition at the beginning of the document. Based on personal experience, it was found out that if the phone does not meet the line at the beginning of the file (and if this phone is Nokia :))

    then he refuses to show the page.

    Further more. Doctype must be specified.
    For the html version of the page, I used
    www.wapforum.org/DTD/xhtml-mobile10.dtd »>

    And for wml
    " Www.wapforum.org/DTD/wml_1.1.xml ">


    Further, it is to your taste, only observing the validity of layout. The validator is at your service.

    Practice. Server side


    As I already wrote, all code examples will be in C #.

    The first task that confronted me was to determine whether the wap browser was in front of me or not.
    I wrote the following:
       bool WapBrowser = Request.Headers ["Accept"]. Contains ("text / vnd.wap.wml");

    Next, we determine whether our browser supports xhtml
       bool SupportHTML = Request.Headers ["Accept"]. Contains ("text / html");

    Everything is clear here too.

    Now you can build several conditions:

    if (SupportHTML && WapBrowser)
    {
       try
        {
          Server.Transfer ("SampleWapPage.aspx");
         }
        catch (Exception ex)
        {
           //
         }
        Server.Transfer ("404.aspx");
    }

    As you can see, if the client’s browser is a wap browser and it supports html, it switches to SampleWapPage.aspx.

    And if the condition is not met, we just try to determine the wap browser:

    if (WapBrowser)
    {
       try
        {
          Server.Transfer (“SampleWapPage.aspx? Wml ");
         }
        catch (Exception ex)
        {
           //
         }
        Server.Transfer ("404.aspx");
    }

    As you can see, everything is simple and clear.
    Good luck to use :)

    Also popular now: