⬆️ ⬇️

Some features of wap programming

Good afternoon, dear. I prefer to read the topics in which not some abstract things are covered, 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 all server part will be on C #.





Preamble



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



A bit of theory



What is html explain, I think, it is not necessary :)

But on wml worth a little stop. Some facts about this markup language:

')

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


More on wiki

In fact, wml is not used anywhere else. The kingdom of xhtml came :)



Practice. Client part



The first thing that I learned when imposing wap pages - without the doctype anywhere.

Second - some phones only display the page with a fully valid layout.



How to ensure that the phone displays your page that has already been laid out under small screens?

It is necessary that it passes the validation!

And for this you need an xml definition at the beginning of the document. Based on personal experience, it was found that if the phone does not meet the line at the beginning of the file (and if this phone is Nokia :))

<? xml version = "1.0" encoding = "UTF-8"?>


then he refuses to show the page.



Further more. You need to specify a doctype.

For html version of the page I used

<! DOCTYPE html PUBLIC "- // WAPFORUM // DTD XHTML Mobile 1.0 // EN" " www.wapforum.org/DTD/xhtml-mobile10.dtd ">


And for wml

<! DOCTYPE wml PUBLIC "- // WAPFORUM // DTD WML 1.1 // EN"

" Www.wapforum.org/DTD/wml_1.1.xml ">




Further already on your taste, only observing the validity of the layout. Validator of everything at your service.



Practice. Server part



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



The first task that stood before me is to determine whether the wap browser is in front of me or not.

I wrote the following:

bool WapBrowser = Request.Headers ["Accept"]. Contains ("text / vnd.wap.wml");



Next, determine whether our browser supports xhtml

bool SupportHTML = Request.Headers ["Accept"]. Contains ("text / html");



Here, too, everything is clear.



Now we 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, 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 in use :)

Source: https://habr.com/ru/post/21700/



All Articles