ASP.NET的 MVC架構

來源:互聯網
上載者:User

你是否正在尋找適合您的.NET開發架構?
你是否是MVC結構的忠實擁護者?

Mavrick.Net 是你最好的選擇!
 
  Mavrick.net 是Open source的.NET MVC架構軟體,你可以通過

http://mavnet.sourceforge.net/ 下載最新的版本及使用說明。
 
以下是Mavrick.net 的一些說明:
 
一 系統需求:
     1. 作業系統:Win2000 (含IIS)    
     2. MS .NET SDK
 
二 安裝過程:
     1. 解開下載完成的Marvice.net安裝包
     2. 開啟IIS設定三個虛擬目錄
         Friendbook  -> 對應 Maverick\examples\Friendbook 目錄
         Friendbook-xsl -> 對應 Maverick\examples\Friendbook-xsl 目錄
  Calendar -> 對應 Maverick\examples\Calendar目錄
 
      3. 在虛擬目錄Friendbook點擊滑鼠右鍵  點擊配置,在快顯視窗,
        設定
           可執行檔為:

C:\WINNT\Microsoft.NET\Framework\v1.0.3705\aspnet_isapi.dll
           添加按展名: .m 
          
      4. 訪問 http://localhost/Friendbook 
       
 三 系統分析

   "Maverick.config"是Mavrick.net的核心,他的功能與Struct中的

struts-config.xml功能是相同的
 

-------------------------------------------------------------------------

----------
 <maverick version="2.0">
  <commands>
    <command name="runQuery">
      <controller class="Bar.Foo.Query, Foobar"/>
      <view name="success" type="document" path="queryResult.aspx">
        <transform type="xslt" path="lookAndFeel.xsl"/>
      </view>
      <view name="error" type="document" path="queryFailed.aspx">
        <transform type="xslt" path="lookAndFeel.xsl"/>
      </view>
    </command>
  </commands>
</maverick>
 

-------------------------------------------------------------------------

----------         
  此例中只定義一個command 即runQuery , 它包含兩種Views即 “success”  和 “error

”。
 
  <controller class="Bar.Foo.Query, Foobar"/>
   
    表明此command 的控制類為Bar.Foo.Query, 此類為流程式控制制, Mavrice.NET 將自動

調用此類中的
    Perform()方法,並根據此方法的返回結果,跳轉到相關的View去,執行後繼的邏輯。

 

-------------------------------------------------------------------------

----------
   // Classname : Bar.Foo.Query.cs  
 using System;
 
 namespace Bar.Foo
 {
  public class Query : ControllerProtected
  {
   public override string Perform()
   {
    if (loginSuccessBool)
     return SUCCESS;
    else
     return ERROR;
   }
  }
 }
 

-------------------------------------------------------------------------

----------
 
  四,部分程式碼
  
    <!--default.aspx-->
    <%@ Page %>
 <%
  Context.Response.Redirect("welcome.m");
 %>

  
  
  
   <!--maverick.config-->
  
   <?xml version="1.0"?>

  <maverick version="2.0" default-view-type="document"

default-transform-type="document">
 
 <views>
  <view id="loginRequired" path="loginRequired.aspx">
   <transform path="trimOutside.aspx"/>
  </view>

  <view id="loginFailed" path="loginFailed.aspx">
   <transform path="trimOutside.aspx"/>
  </view>
 </views>

 <commands>
  <command name="welcome">
   <view path="welcome.aspx">
    <transform path="trimOutside.aspx"/>
   </view>
  </command>

  <command name="signup">
 
 ..................
 
 </commands>
 

  </maverick>
 

 
  <!-- welcome.aspx-->
 
  <%@ Page %>
  <%
 Context.Items.Add("title","Welcome");
  %>

  <p>
 Welcome to the Friendbook example.  This is a simple contact-list
 application which demonstrates how to create a membership-based
 website with Maverick.
  </p>

 <%
 Context.Items.Add("dest","friends.m");
 Context.Server.Execute("loginForm.aspx");
  %>

  <!--trimOutside.aspx-->

  <%@ Page %>
 <html>
 <head>
  <title> <%=Context.Items["title"]%> </title>
  <link rel="stylesheet" href="stylesheet.css"

type="text/css" />
 </head>

 <body>
  <table cellspacing="0" cellpadding="0" width="100%">
   <tr>
    <td class="pageTitle"

colspan="2"><h1><h1> <%=Context.Items["title"]%></h1></td>
   </tr>
   <tr align="center" style="text-align: center">
    <td class="navigationTop"> <a class="nav"

href="welcome.m">Login</a></td>
    <td class="navigationTop"> <a class="nav"

href="signup.m">Sign Up</a></td>
   </tr>
  </table>

  <%=Context.Items["wrapped"]%>
 </body>
</html>

望共同提高!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.