Search code examples
c#asp.net-mvcvirtualpathprovider

Override some Methodes of VirtualPathProvider


I want to use the default implemented VirtualPathProvider of ASP.Net MVC Web Application.

In other words I want to inherit my own VirtualPathProvider from default Asp.net VirtualPathProvider and just override the GetCacheKey Method.

What should I do?

Anyone can help?

Cheers


Solution

  • Create your custom virtual path provider class, overriding the method you want, and then call HostingEnvironment.RegisterVirtualPathProvider from within Application_Start (defined in global.asax.cs) to install it:

    protected void Application_Start() {
        HostingEnvirontment.RegisterVirtualPathProvider(new MyVPProvider());
    }