ASP.NET: Getting Context

Reminder: Normally, in asp.net 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);

You May Also Like

About the Author: rnowik

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.