17

How can I access the HttpServerUtility instance in ASP.NET MVC controller?

1 Answer 1

46

"this.httpContext.Server" is a reference to HttpServerUtilityBase, the abstract class wrapper that's a part of the System.Web.Abstractions DLL. You can also do:

HttpContext.Current.Server

To directly access the "old-school" way. Also you can get an instance of the base class using the wrapper by doing the following:

new HttpServerUtilityWrapper(HttpContext.Current.Server)

The wrapper class inherits from httpServerUtilityBase

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.