예제 #1
0
        public ILocalResourceLocation FindResource(string url, IDotvvmRequestContext context, out string mimeType)
        {
            mimeType = null;
            if (DotvvmRoutingMiddleware.FindMatchingRoute(new[] { resourceRoute }, context, out var parameters) == null)
            {
                return(null);
            }

            var name = DecodeResourceName((string)parameters[NameParameterName]);
            var hash = (string)parameters[HashParameterName];

            if (resources.FindResource(name) is IResource resource)
            {
                var location = FindLocation(resource, out mimeType);
                if (GetVersionHash(location, context, name) == hash) // check if the resource matches so that nobody can guess the url by chance
                {
                    if (alternateDirectories != null)
                    {
                        alternateDirectories.GetOrAdd(hash, _ => (location as IDebugFileLocalLocation)?.GetFilePath(context));
                    }

                    return(location);
                }
            }

            return(TryLoadAlternativeFile(name, hash, context));
        }
예제 #2
0
        public ILocalResourceLocation?FindResource(string url, IDotvvmRequestContext context, out string?mimeType)
        {
            mimeType = null;
            if (DotvvmRoutingMiddleware.FindMatchingRoute(new[] { resourceRoute }, context, out var parameters) == null)
            {
                return(null);
            }

            var name = DecodeResourceName((string)parameters ![NameParameterName] !);