.net - ASP.NET MVC, ActionFilters, static classes and passing data around -


I want to hear your opinion and possibly a better suggestion for this scenario:

I have Defines a custom action filter that does some work and comes out with some value. I would like to use that value in controlling tasks and in the model.

Now, I can use TempData to pass this value from any controller function method to the actionfilter, then distribute this value in all the models that meet the returned ideas done.

I'm sure this will work, but there will be no where there is really no need for this in the Temptata session.

I have come up with two options:

  1. In the actionfilter, I set this value in Tempadata in Onactive Except () and I did it on Removed in () () Do I understand it correctly that from time to time it is said to take action, the action of the controller is over, the response has already been generated and this tempadata content is not making the session its way?

  2. In any of my custom static classes (logic) I only define a public property for this value and I use it whenever I need it Will this static field not be lost between the on-one acquisition () and can actually execute the controlling method? Is there any other issue with losing this value during the processing request on the server?

Is there any other / better option I have not yet been considered?

I've found that using your code Code: ActionParameters is very easy to test your code. makes. You can do it like this:

  // On your own actionfinder public override zero, on the process of integration (ActionX signin context context) {var someData = // ... load some data references. Action Parameters ["Some Data"] = Some Data; } // and then the public ViewResult Index (SomeData someData) in its verb method [ProvideSomeData] {// some data will be populated here}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -