I have mocked Server Variables which are used in Controller.
request.SetupGet(x => x.ServerVariables)
.Returns(new System.Collections.Specialized.NameValueCollection
{
{"SERVER_NAME","localhost"},
{"SCRIPT_NAME","localhost"},
{"SERVER_PORT","80"},
{"HTTPS","www.melaos.com"},
{"REMOTE_ADDR","127.0.0.1"},
{"REMOTE_HOST","127.0.0.1"}
});
I can get the values of Server variables in Controller but not in Model classes. Why is it so?
The only difference in getting the value in Controller and Model is that in Controller we write HttpContext.Request.ServerVariables
while in Model we write HttpContext.Current.Request.ServerVariables
.
Are they different? How can I get these values in Model as well.