Gets or sets the current item.
The Item identified by the "path" query string parameter, or null if the item was not found.
The current item is the context item from which the web page is rendered. For instance if the current item points to the Home item, the web engine will render the layout associated with the Home item.
The current web item is by default obtained by parsing the Path argument on the request query string.
The value is checked for validity by verifying that the root item of the value is the Sitecore root item (see RootID). If this is not the case, that value is considered invalid and the value is refreshed. This situation may occur if the current item for some reason is removed from the internal data structure.
The scope of the value is page and it is stored in the Items variable "sc_CurrentItem".
The following example redirects the page, if the current item has a specific name.
[CS]
public void Redirect(string name, string url) {
Item item = State.CurrentItem;
if (item.Name == name) {
Response.Redirect(url);
}
}
Context Class | Sitecore Namespace