Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
743
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
4
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • ActionMethodSelectorAttribute
  • FilterAttribute
  • ActionNameSelectorAttribute

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