Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

DI through constructor in WebViewPageBase not working. #1494


User avatar
0
sparkyjr created

Hi,

I am trying to inject a service through the constructor in WebViewPageBase.cs lying in Web Project -> Views -> WebViewPageBase but its not allowing. Does Dependency Injection through the constructor not work for WebViewPageBase.cs class?

Thanking you in advance.


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can use IocManager.Instance.Resolve<>() in your case. Initial project template injects AbpSession like this,

    public abstract class MyCompanyWebViewPageBase<TModel> : AbpWebViewPage<TModel>
    {
        public IAbpSession AbpSession { get; private set; }
        
        protected MyCompanyWebViewPageBase()
        {
            AbpSession = IocManager.Instance.Resolve<IAbpSession>();
            LocalizationSourceName = ChatTesterConsts.LocalizationSourceName;
        }
    }