_ViewImports.cshtml question
-
This question is about a net core Web app Hi all , if I put this line in _ViewImports.cshtml (where IPageSettings is in the IServiceCollection)
@inject IPagingSettings PageSettings;
PageSettings is available in all my views EXCEPT _layout.cshtml, anyone know why ? I can't find anything with Mr Google
Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
-
This question is about a net core Web app Hi all , if I put this line in _ViewImports.cshtml (where IPageSettings is in the IServiceCollection)
@inject IPagingSettings PageSettings;
PageSettings is available in all my views EXCEPT _layout.cshtml, anyone know why ? I can't find anything with Mr Google
Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
According to the documentation[^],
_ViewImports
should apply to every page, including layouts and partial views, whereas_ViewStart
doesn't apply to layouts or partial views. There must be something else going on. What's the hierarchy of your views folder, and what's the error message you're getting?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
According to the documentation[^],
_ViewImports
should apply to every page, including layouts and partial views, whereas_ViewStart
doesn't apply to layouts or partial views. There must be something else going on. What's the hierarchy of your views folder, and what's the error message you're getting?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
It's the standard hierarchy Richard - _ViewImports.cshtml is in the root Views folder - there is no error it's (the var) not available when I try and use it with @PageSettings, in all the other views I get intellisense Edit I should mention that, if I put the same @inject statement directly in _layout.cshtml it works
Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
-
It's the standard hierarchy Richard - _ViewImports.cshtml is in the root Views folder - there is no error it's (the var) not available when I try and use it with @PageSettings, in all the other views I get intellisense Edit I should mention that, if I put the same @inject statement directly in _layout.cshtml it works
Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
"Not available" as in "not listed by intellisense", or does it not compile if you try to use it?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
"Not available" as in "not listed by intellisense", or does it not compile if you try to use it?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Good call Richard it does actually work but I don't like red squigglies - I've noticed the same with the using statements, same thing intellisense works in all views except _layout where I'm prompted to add the full namespace.class
Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP