private void Refresh() { var relativeUri = NavigationManager.ToBaseRelativePath(_location); var hash = string.Empty; if (relativeUri.IndexOf('#') >= 0) { hash = relativeUri.Substring(relativeUri.IndexOf('#'), relativeUri.Length - relativeUri.IndexOf('#')); relativeUri = relativeUri.Substring(0, relativeUri.IndexOf('#')); } var currentCulture = LanguageService.CurrentCulture; var segment = relativeUri.IndexOf('/') > 0 ? relativeUri.Substring(0, relativeUri.IndexOf('/')) : relativeUri; if (string.IsNullOrWhiteSpace(segment)) { NavigationManager.NavigateTo($"{currentCulture.Name}/{relativeUri}", true); return; } else { if (segment.IsIn("zh-CN", "en-US")) { LanguageService.SetLanguage(CultureInfo.GetCultureInfo(segment)); } else if (currentCulture.Name.IsIn("zh-CN", "en-US")) { NavigationManager.NavigateTo($"{currentCulture.Name}/{relativeUri}", true); } else { NavigationManager.NavigateTo($"en-US/{relativeUri}", true); return; } } var matchResult = RouteManager.Match(relativeUri); if (matchResult.IsMatch) { var routeData = new RouteData(matchResult.MatchedRoute.PageType, matchResult.MatchedRoute.Parameters); _renderHandle.Render(Found(routeData)); } else { if (!string.IsNullOrEmpty(DefaultUrl)) { NavigationManager.NavigateTo($"{currentCulture}/{DefaultUrl}", true); } _renderHandle.Render(NotFound); } if (!string.IsNullOrWhiteSpace(hash)) { if (JsRuntime.IsBrowser()) { ((IJSInProcessRuntime)JsRuntime).InvokeVoid(JSInteropConstants.ScrollTo, $"{hash}"); } else { Task.Run(() => JsRuntime.InvokeVoidAsync(JSInteropConstants.ScrollTo, $"{hash}")); } } }