I am currently working on a project with a plugin-like system. After starting a web project, he searches for plug-ins plugins and creates a graphical interface. DLL files contain embedded views and embedded resources such as images or javascripts.
I am using RazorGenerator (VS Plugin) to generate cs files from views. The view assembly action is set to "embedded resource" and the custom tool is set to "RazorGenerator"
I use my own virtual path provider (very similar to this one )
I am registering a virtual path provider with this workaround that I found on the network (this is necessary because it does not work as intended if I do not use it):
var assemblyResourceProvider = new AssemblyResourceProvider(); var hostingEnvironmentInstance = (HostingEnvironment)typeof(HostingEnvironment).InvokeMember("_theHostingEnvironment", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null); if (hostingEnvironmentInstance == null) return; var mi = typeof(HostingEnvironment).GetMethod("RegisterVirtualPathProviderInternal", BindingFlags.NonPublic | BindingFlags.Static); if (mi == null) return; mi.Invoke(hostingEnvironmentInstance, new object[] { assemblyResourceProvider });
I use this on my RouteConfig.cs to create inline script and image files:
routes.IgnoreRoute("{*staticfile}", new { staticfile = @".*\.(css|js|gif|png|jpg|exe)(/.*)?" });
I add these lines (there are more) to my web.config to tell asp to use my path provider for my inline sources:
<add name="AspNetStaticFileHandler-PNG" path="*.png" verb="GET,HEAD" type="System.Web.StaticFileHandler"/>
I am using doc Boc.Web.PrecompiledViews to register path attributes generated by RazorGenerator
BoC.Web.Mvc.PrecompiledViews.ApplicationPartRegistry.Register(assembly);
Everything works in Visual Studio. The views and resources built into the dll demonstrate and work flawlessly. I also use IIS 7.5 to run my web application from Visual Studio. All possibilities:
- it works if I give a virtual path created by the Razor generator (for example: ~ ~ / Views / ViewTest / Test)
- it works if I give the path to the Dll resources that uses my resource resource (for example: "DllResources / ViewTest.dll / Views / ViewTest / Test.cshtml)
However, after deploying my web application and launching it using IIS 7.5, views (view-only!) Do not appear! If I address representations with a virtual path (option 1), IIS displays this error message:
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
if I address the view using the DllResources path (option 2), IIS throws this error message:
The file '/Views/ViewTest/DllResources/EmbeddedResourceTest/Views/ViewTest/Test.cshtml' has not been pre-compiled, and cannot be requested.
I do not know what to do now to make it work. I tried to replace every step with other solutions. The result is the same. Works flawlessly in VS, but views are not displayed after deployment.
Is this some kind of configuration for IIS, what's missing? Am I missing something from web.config? Please help me with this problem.
Thanks Norbert
source share