2009-10-06 3 views
2

ASP.NET-MVC를 사용하여 WAP 사이트를 구현할 계획입니다.ASP.NET-MVC를 사용하여 WAP 사이트 구현

누구에게도이 경험이 있습니까? 어떤 잡티가 있습니까?

또한 브라우저 용 "표준"웹 사이트를 구현할 예정입니다. 단일 모델 세트와 컨트롤러를 가질 수 있으며 각 사이트에 대해 별도의 뷰를 가질 수 있습니까?

+0

귀하의 사이트가 될 것입니다 WAP1/WML 또는 WAP 2/XHT 사용 ML1.2? –

답변

3

대부분의 경우 단일 모델 세트와 컨트롤러를 가질 수 있습니다. 그 방법은 다음 Theming/Templating 엔진을 구현하는 것입니다. [Theming Support] [1] Theming/Templating 엔진 위에 내 솔루션을 보냈습니다.

protected void Application_BeginRequest(Object Sender, EventArgs e) 
{ 
    SetTheme(); 
} 
//this will set the responses Content Type to xhtml and is necessary as C# sends the WML response header 
protected void Application_PreSendRequestHeaders(Object Sender, EventArgs e) 
{ 
    if (this.Context.Items["themeName"].ToString() == "xhtml") 
    { 
    this.Context.Response.ContentType = "application/vnd.wap.xhtml+xml"; 
    } 
} 

private void SetTheme() 
{ 
    //set the content type for the ViewEngine to utilize. 

      HttpContext context = this.Context; 
      MobileCapabilities currentCapabilities = (MobileCapabilities)context.Request.Browser; 
      String prefMime = currentCapabilities.PreferredRenderingMime; 

      string accept = context.Request.ServerVariables["HTTP_ACCEPT"]; 
      context.Items.Remove("theme"); 
      context.Items.Remove("themeName"); 

      if (accept.Contains("application/vnd.wap.xhtml+xml")) 
      { 
       context.Items.Add("themeName", "xhtml"); 
      } 
      else if (prefMime == "text/vnd.wap.wml") 
      { 
       context.Items.Add("themeName", "WAP"); 
      } 
      if (!context.Items.Contains("themeName")) 
      { 
       context.Items.Add("themeName", "Default"); 
      } 
     } 

내가 코드 변경의 몇을했습니다 알고

문서 소스에서 주요 편차는 다음 코드 줄을 추가해야 할 경우 파일 Global.asax.cs에 그것 MVC 1 호환,하지만 정확한 변화를 기억할 수 없다. 다른 주요 문제는 출력 디버깅이었습니다. 이를 위해 나는 파이어 폭스 (Firefox)를 확장하여 ([User Agent Switcher] [2]) 확장 기능을 추가했다. WAP2/XHTML1.2를 들어

수락 유형은 다음과 같습니다 : text/html과, 응용 프로그램/vnd.wap.xhtml + XML, 응용 프로그램/XHTML + XML, 응용 프로그램/XML, Q = 0.9, 이/, Q = 0.8 분명히

당신은 WML 또는 XHTML1.2을 준수하기 위해 masterpage 및 콘텐츠 페이지를 필요

[1] : http://frugalcoder.us/post/2008/11/13/ASPNet-MVC-Theming.aspx 주제 선정 지원

[2] : http://chrispederick.com/work/user-agent-switcher/ 사용자 에이전트 스위처는

+0

덕분에 도움이 많이 –

+0

내 기쁨 :). –