ASP.NET: Getting Context

Reminder: Normally, in you get context from the current page object, however this is not always possible (e.g. if you are coding a separate dll that does not implicitly have context). To get context from the caller within the dll, HttpContext.Current. The example below shows mapping an image url to a filepath.

filePath = System.Web.HttpContext.Current.Server.MapPath(imgUrl);

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>