Reputation: 13357
I have the following MVC TypeFormatter code and I need assistance how to:
Pass values into this object or reference them from the controller get method
public class ObjectSomeTypeOfFormatter : MediaTypeFormatter
{
public override Task WriteToStreamAsync(Type type, object value, Stream stream, HttpContentHeaders contentHeaders, TransportContext transportContext)
{
// Method that I'm overriding where I need to access some variables defined from controller.
}
}
Upvotes: 0
Views: 307
Reputation: 32768
Access the Request object to get the full/relative path but it's not available.
You can get it from HttpContext.Curent.Request
and for that you need to have reference to System.Web
asembly.
Upvotes: 1