asp.net mvc - Is this possible to call the System.Web.HttpContext.Current.Request.Url in C# Models function? -
i want asp.net mvc domain in c# code (model function). trying call function on string it's not worked.
string domain = "" + system.web.httpcontext.current.request.url;
when tried call same in controller's actionresult work in c# models it's not work.
i hope context make work it's not worked.
someone please explain me if else can use. want getting url , want not pass url (domain) form every call.
httpcontext.current
work if code executed within existing http context. example code return null if attempt execute in unit test. terribly bad practice rely on httpcontext specific things in models. property set in controller (where have access httpcontext) , pass model dal , service layers property populated.
Comments
Post a Comment