What's a context in asp.net mvc4? Loads of classes use this term. DbContext, HttpContext and so on. I think that if I know the meaning to this word I will have a better understanding of asp.net mvc.

有帮助吗?

解决方案

I feel http://dictionary.reference.com/browse/context defines the word 'context' as it applies generally and indeed in the specific context (forgive me) to which you refer, particularly

2: the set of circumstances or facts that surround a particular event, situation, etc.

Consider the classes a model of this "set of circumstances or facts" surrounding the particular event occuring, e.g a DB operation or HTTP request.

DbContext represents a given context pertinent to the database. That is, one might interface with a database in the context of "reporting" or in the context of "migration", or one might consider each interaction with the database a seperate context from the last.

Similarly one might make use of the HTTP protocol in several different contexts. Each use of the protocol may constitute a different context, i.e one context per request. Or it may refer to the context in which it is utilised i.e for persistence or for querying.

It is a rather common expression and is just an aptly descriptive english term for the designated function of each of the classes mentioned in your question. Don't get too hung up on the precise meaning and inference of each class name; base your decisions on a full read of the documentation :)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top