문제

I have number of projects that use different view engines (razor and webform). I want to share a partial view between them. I want to put my partial view in base project and just link partial views in my projects to it.

Looks like it isn't possible because partial view in razor and webform inherited from different base classes. Is it possible to hack this?

도움이 되었습니까?

해결책

It was more simple that I though. WebForm can't take in Razor partial view. BUT Razor view engine takes in WebForm partial view. So it isn't issue at all.

What I did.

  1. Create some shared project.
  2. Add Partial.ascx file (and some js files) in sub folder of this shared project.
  3. Add reference to this project to my sub projects.
  4. Add as link partial view (and some js files) to sub projects.

So now we have partial view that is shared between number of projects.

PS: Be aware, my projects have only one view engine for improving performance. All other were removed: ViewEngines.Engines.Clear(); and added ViewEngines.Engines.Add(new RazorViewEngine()); Razor only. So I have to remove this code from my Global.asax file.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top