Search Results

Search found 6 results on 1 pages for 'virtualpathprovider'.

Page 1/1 | 1 

  • Running a custom VirtualPathProvider with a PreCompiled website

    - by epilog
    Hi, currently I have a custom VirtualPathProvider in a Asp.net MVC web application. This VirtualPathProvider checks the Area from the route "/{Area}/{Controller}/..." and uses the NameSpace.{Area}.Main.dll module to return the views that are contained in that assembly as Embedded Resources. This works great and I don't have to deploy any ascx, js, css files. Now my problem is this: I would like to precompile the aspx and ascx files in the assembly and instead of having the views as embedded resources I would have the view class with all the Response.Write and dings and dongs. I can precompile the views using the aspnet_compiler but I keep getting an error when ever the ViewEngine tries to find the view and fails. My main goal is to have a way for the first time usage of a certain view/usercontrol would be faster and don't wait for the compilation to happen. This is a requirement since the application could be grouped into plugins and this plugins be deployed into the Bin directory. Any thoughts? With best regards Carlos Sobrinho

    Read the article

  • Asp.net MVC VirtualPathProvider views parse error

    - by madcapnmckay
    Hi, I am working on a plugin system for Asp.net MVC 2. I have a dll containing controllers and views as embedded resources. I scan the plugin dlls for controller using StructureMap and I then can pull them out and instantiate them when requested. This works fine. I then have a VirtualPathProvider which I adapted from this post public class AssemblyResourceProvider : VirtualPathProvider { protected virtual string WidgetDirectory { get { return "~/bin"; } } private bool IsAppResourcePath(string virtualPath) { var checkPath = VirtualPathUtility.ToAppRelative(virtualPath); return checkPath.StartsWith(WidgetDirectory, StringComparison.InvariantCultureIgnoreCase); } public override bool FileExists(string virtualPath) { return (IsAppResourcePath(virtualPath) || base.FileExists(virtualPath)); } public override VirtualFile GetFile(string virtualPath) { return IsAppResourcePath(virtualPath) ? new AssemblyResourceVirtualFile(virtualPath) : base.GetFile(virtualPath); } public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart) { return IsAppResourcePath(virtualPath) ? null : base.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart); } } internal class AssemblyResourceVirtualFile : VirtualFile { private readonly string path; public AssemblyResourceVirtualFile(string virtualPath) : base(virtualPath) { path = VirtualPathUtility.ToAppRelative(virtualPath); } public override Stream Open() { var parts = path.Split('/'); var resourceName = Path.GetFileName(path); var apath = HttpContext.Current.Server.MapPath(Path.GetDirectoryName(path)); var assembly = Assembly.LoadFile(apath); return assembly != null ? assembly.GetManifestResourceStream(assembly.GetManifestResourceNames().SingleOrDefault(s => string.Compare(s, resourceName, true) == 0)) : null; } } The VPP seems to be working fine also. The view is found and is pulled out into a stream. I then receive a parse error Could not load type 'System.Web.Mvc.ViewUserControl<dynamic>'. which I can't find mentioned in any previous example of pluggable views. Why would my view not compile at this stage? Thanks for any help, Ian EDIT: Getting closer to an answer but not quite clear why things aren't compiling. Based on the comments I checked the versions and everything is in V2, I believe dynamic was brought in at V2 so this is fine. I don't even have V3 installed so it can't be that. I have however got the view to render, if I remove the <dynamic> altogether. So a VPP works but only if the view is not strongly typed or dynamic This makes sense for the strongly typed scenario as the type is in the dynamically loaded dll so the viewengine will not be aware of it, even though the dll is in the bin. Is there a way to load types at app start? Considering having a go with MEF instead of my bespoke Structuremap solution. What do you think?

    Read the article

  • Instantiate an .aspx that is an embedded resource of an assembly

    - by asbjornu
    I have an ASP.NET (MVC) application in which I would like to load WebForms .aspx files that are embedded as resources in 3rd party assemblies. The reason I want to do this is to make a sort of "plug-in" system where a .dll file can be dropped in a folder and then picked up at runtime to provide additional functionality to the base application. I've gotten the plugin system to work (I'm using MEF) with plugins written in ASP.NET MVC (Views and Controllers), but for plain old ASP.NET (Pages), I've got myself into a bit of a problem. For the execution of the embedded .aspx file (which, in the usual WebForm way Inherits="My.BasePage") I've created a custom VirtualPathProvider, ResourceFile ControllerFactory and PageController. Within the PageController I've overridden the Execute(RequestContext) method and within it I'm trying to compile the .aspx with BuildManager.CreateInstanceFromVirtualPath(virtualPath, type). When doing this, I get the error message "Could not load type 'My.BasePage'", even though I'm giving the BuildManager the System.Type of My.BasePage in the call to CreateInstanceFromVirtualPath. I seem to be stuck at this point. I've tried to Server.Transfer() to the custom VirtualPathProvider handled URL to the same .aspx file, but that fails with the same error message. How can I help BuildManager find out where My.BasePage is defined and how come the Type requiredBaseType parameter of CreateInstanceFromVirtualPath seems to be ignored? I've tried to call BuildManager.AddReferencedAssembly(), but that only fails with "This method can only be called during the application's pre-start initialization stage". MSDN says: "The method must be called during the Application_PreStartInit stage of the application", but I have no such event in my HttpApplication object and find absolutely zero information about it on the internet. Either way, I don't want to be calling BuildManager.AddReferencedAssembly() in or before the Application_Start event, since that makes me have to recycle the whole application to be able to add new plugins to the system. Does anyone have any clues? Any other ideas on how I can "execute" an .aspx file that is embedded as a resource within an assembly through reflection? Can I for instance pre-compile the .aspx file within the same assembly as the base Page class it inherits?

    Read the article

  • Implementing Custom CacheDependency to invalidate ASP.Net cache item

    - by Ajay
    Hi, I want to implement my own customCacheDependency class by deriving base CacheDependency, as provided SqlCacheDependency is not suitable for my case. (thousands of cache items, and there will so many subscriptions in SQL as well as issues with registration in ASP.Net) I want to use this in ASP.Net VirtualPathProvider's our custom implementation, so I can pass this CustomCacheDependecy to notify the asp.net that file content in the DB has changed. Can some one point me to any custom implementation of CacheDependency (preferably using MessageQueue)? Thanks & Regards, Ajay

    Read the article

  • Embedded strongly-typed views with ASP.NET MVC

    - by Brian Vallelunga
    I'm working on a plugin-type of system for ASP.NET MVC that loads views from an embedded assembly. I have created a VirtualPathProvider that does the work of retrieving out of the assembly. Everything is working fine except for strongly-typed views. Whenever I try to load one of those, I get an exception of: Could not load type 'System.Web.Mvc.ViewPage'. The problem is that there is no Web.config file under the Views folder. Well, actually there is, but the system doesn't seem to want to read the embedded version. If I manually create the file under the corresponding directory in the web app, everything is fine. This isn't an acceptable workaround however, as each plugin would need its own file in its own specific directory. Does anyone know how I might get ASP to read the embedded Web.config file? Thanks, Brian

    Read the article

  • Configure IIS7 to server static content through ASP.NET Runtime

    - by Anton Gogolev
    I searched high an low and still cannot find a definite answer. How do I configure IIS 7.0 or a Web Application in IIS so that ASP.NET Runtime will handle all requests -- including ones to static files like *.js, *.gif, etc? What I'm trying to do is as follows. We have kind of SaaSy site, which we can "skin" for every customer. "Skinnig" means developing a custom master page and using a bunch of *.css and other images. Quite naturally, I'm using VirtualPathProvider, which operates like this: public override System.Web.Hosting.VirtualFile GetFile(string virtualPath) { if(PhysicalFileExists(virtualPath)) { var virtualFile = base.GetFile(virtualPath); return virtualFile; } if(VirtualFileExists(virtualPath)) { var brandedVirtualPath = GetBrandedVirtualPath(virtualPath); var absolutePath = HttpContext.Current.Server.MapPath(brandedVirtualPath); Trace.WriteLine(string.Format("Serving '{0}' from '{1}'", brandedVirtualPath, absolutePath), "BrandingAwareVirtualPathProvider"); var virtualFile = new VirtualFile(brandedVirtualPath, absolutePath); return virtualFile; } return null; } The basic idea is as follows: we have a branding folder inside our webapp, which in turn contains folders for each "brand", with "brand" being equal to host name. That is, requests to http://foo.example.com/ should use static files from branding/foo_example_com, whereas http://bar.example.com/ should use content from branding/bar_example_com. Now what I want IIS to do is to forward all requests to static files to StaticFileHandler, which would then use this whole "infrastructure" and serve correct files. However, try as I might, I cannot configure IIS to do this.

    Read the article

1