0
ASP.NET MVC - Action
JASON
ASP.NET MVC-Action


What 「Action method」



Action attribute



Custom Action Result
Action of Controller
What 「Action method」 ?
Action of Controller


必須是 public



不可以是 static



不可以是 extension method



不可以是建構子、getter 或 setter



不可以是 Generic ...
NonAction Attribute


Represents an attribute that is used to indicate that a controller
method is not an action method.
ChildActionOnly Attribute


Represents an attribute that is used to indicate that an action
method should be called only ...
Html.Action VS Html.RenderAction


Html.Action




Invokes the specified child action method with the specified
paramet...
ActionName Attribute


Represents an attribute that is used for the name of an action.
Custom Action Results


不同 action ,相同 result , 導致重複的程式碼



action 裡,含有難以測試的程式碼
Custom Action Results


使用 action result 消除重複的程式碼
Custom Action Results


使用 action result 抽象化難以測試的相依性
Reference


Controllers and Action Methods in ASP.NET MVC Applications


http://msdn.microsoft.com/en-US/library/dd41026...
Upcoming SlideShare
Loading in...5
×

Asp.net controller

800

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
800
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • ActionMethodSelectorAttribute
  • FilterAttribute
  • ActionNameSelectorAttribute
  • Transcript of "Asp.net controller"

    1. 1. ASP.NET MVC - Action JASON
    2. 2. ASP.NET MVC-Action  What 「Action method」  Action attribute  Custom Action Result
    3. 3. Action of Controller What 「Action method」 ?
    4. 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. 5. NonAction Attribute  Represents an attribute that is used to indicate that a controller method is not an action method.
    6. 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. 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. 8. ActionName Attribute  Represents an attribute that is used for the name of an action.
    9. 9. Custom Action Results  不同 action ,相同 result , 導致重複的程式碼  action 裡,含有難以測試的程式碼
    10. 10. Custom Action Results  使用 action result 消除重複的程式碼
    11. 11. Custom Action Results  使用 action result 抽象化難以測試的相依性
    12. 12. Reference  Controllers and Action Methods in ASP.NET MVC Applications  http://msdn.microsoft.com/en-US/library/dd410269(v=vs.100).aspx
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×