To refer SPWeb object sometimes we use SPContext.Current.Web or SPContext.Current.Site.OpenWeb(). Here we will see What are differences between SPContext.Current.Web and SPContext.Current.Site.OpenWeb()
SPContext.Current.Site.OpenWeb()
- Creates a new instance of the SPWeb object, and we are responsible to dispose after using it.
- OpenWeb() with out sending parameters opens root web of current site collection. If OpenWeb() with parameters opens specific web site.
- Expensive call - It cost more resources than reusing an existing one.
SPContext.Current.Web :
- Gives you access to the current instance of SPWeb, and you must not dispose it
- Gives current Subsite if you are at web other than root web.