Asp.net controller
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Asp.net controller

on

  • 882 views

 

Statistics

Views

Total Views
882
Views on SlideShare
882
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • ActionMethodSelectorAttribute
  • FilterAttribute
  • ActionNameSelectorAttribute

Asp.net controller Presentation Transcript

  • 1. ASP.NET MVC - Action JASON
  • 2. ASP.NET MVC-Action  What 「Action method」  Action attribute  Custom Action Result
  • 3. Action of Controller What 「Action method」 ?
  • 4. Action of Controller  必須是 public  不可以是 static  不可以是 extension method  不可以是建構子、getter 或 setter  不可以是 Generic method  不可以是 Controller baseClass method  不可以是 ControllerBase baseClass method  不可以包含 ref 或 out 參數  不能加上 「NonAction」 action selector attribute
  • 5. NonAction Attribute  Represents an attribute that is used to indicate that a controller method is not an action method.
  • 6. ChildActionOnly Attribute  Represents an attribute that is used to indicate that an action method should be called only as a child action. Action View
  • 7. Html.Action VS Html.RenderAction  Html.Action   Invokes the specified child action method with the specified parameters and returns the result as an HTML string. Html.RenderAction  Invokes the specified child action method and renders the result inline in the parent view.
  • 8. ActionName Attribute  Represents an attribute that is used for the name of an action.
  • 9. Custom Action Results  不同 action ,相同 result , 導致重複的程式碼  action 裡,含有難以測試的程式碼
  • 10. Custom Action Results  使用 action result 消除重複的程式碼
  • 11. Custom Action Results  使用 action result 抽象化難以測試的相依性
  • 12. Reference  Controllers and Action Methods in ASP.NET MVC Applications  http://msdn.microsoft.com/en-US/library/dd410269(v=vs.100).aspx