ASP.NET MVC Controller Action Precondition Filter (blog.troyd.net)

submitted by powerrushpowerrush(3873) 4 years ago

Here is code that will allow you to decorate your MVC Actions with attributes that will define your needed "preconditions". I often find the need to check for the existence of a parameter passed to a web page, such as an ID, and also often need to check if the ID is valid as well (e.g.: a valid primary key). These, I consider "preconditions".

1 comment |category: |Views: 69

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by powerrushpowerrush(3873) 4 years ago 0

As Phil Haack pointed out in the comments, I forgot to mention Postconditions as well:

"By the way, you can also do PostConditions this way too with action filters as we have an OnActionExecuted method that runs before we execute the result."

Reply

information Login or create an account to comment on this story