locked
how to change virtualpath of CreateLocalResourceProvider Method? RRS feed

  • Question

  • User-209105085 posted
    I'm writing a custom resource provider using the technique described in this article http://msdn.microsoft.com/en-us/library/aa905797.aspx.  When i create CustomFactory derived from ResourceProviderFactory i have to override CreateLocalResourceProvider method which takes one parameter "virtualpath" which is eventually being used as resource type. Is there any way to change the virtual path programmatically before its pass to CreateLocalResourceProvider Method?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    So in database if I stored resourceType as “SubDir1/Operations/Expressions.aspx” but my actual page is stored in "SubDir1/Expressions.aspx" virtualpath how do i change it to before it is passed to Factory

    <o:p> </o:p><o:p> </o:p>
    Tuesday, December 11, 2007 12:08 PM

All replies

  • User-209105085 posted

    check the CreateLocalResourceProvider method below,

    public class DBResourceProviderFactory :ResourceProviderFactory
        {
            public override IResourceProvider CreateGlobalResourceProvider(string classKey)
            {
                return new DBResourceProvider(classKey); 
            }
    
            public override IResourceProvider CreateLocalResourceProvider(string virtualPath)
            {
                if (System.Web.HttpContext.Current.Request.QueryString["vp"] != null)
                {
                    //here i wanted to override virtualpath with the one passed in querystring. But if i do this
                    // i get compile time error "Object reference not set to an instance of an object."    why?            
                }           
                string classKey = virtualPath;
                if (!string.IsNullOrEmpty(virtualPath))
                {
                    virtualPath = virtualPath.Remove(0, 1);
                    classKey = virtualPath.Remove(0, virtualPath.IndexOf('/') + 1);
                }
    
                return new DBResourceProvider(classKey);
            }
        }
     
    Tuesday, December 11, 2007 2:20 PM