diff --git a/Jellyfin/Views/OnBoarding.xaml b/Jellyfin/Views/OnBoarding.xaml
index ea8e042..3ae934b 100644
--- a/Jellyfin/Views/OnBoarding.xaml
+++ b/Jellyfin/Views/OnBoarding.xaml
@@ -32,35 +32,46 @@
-
+
-
-
-
-
-
+
+
+
-
-
+ x:Name="txtError"
+ FontFamily="{StaticResource JellyfinFamilyFont}"
+ Text="We're unable to connect to the selected server right now. Please ensure it is running and try again"
+ HorizontalAlignment="Center"
+ TextAlignment="Center"
+ TextWrapping="Wrap"
+ Visibility="Collapsed"
+ FontSize="{StaticResource FontM}"
+ Margin="1 1 1 20"
+ Foreground="#CF4A4A" />
+
diff --git a/Jellyfin/Views/OnBoarding.xaml.cs b/Jellyfin/Views/OnBoarding.xaml.cs
index 08c8ce5..da879c6 100644
--- a/Jellyfin/Views/OnBoarding.xaml.cs
+++ b/Jellyfin/Views/OnBoarding.xaml.cs
@@ -82,8 +82,10 @@ namespace Jellyfin.Views
{
return false;
}
+
//add scheme to uri if not included
Uri testUri = new UriBuilder(uriString).Uri;
+
// check URL exists
HttpWebRequest request;
HttpWebResponse response;
@@ -92,9 +94,33 @@ namespace Jellyfin.Views
request = (HttpWebRequest)WebRequest.Create(testUri);
response = (HttpWebResponse)(await request.GetResponseAsync());
}
- catch (Exception)
+ catch (WebException ex)
{
- return false;
+ // Handle web exceptions here
+ if (ex.Response != null && ex.Response is HttpWebResponse errorResponse)
+ {
+ int statusCode = (int)errorResponse.StatusCode;
+ if (statusCode >= 300 && statusCode <= 308)
+ {
+ // Handle Redirect
+ string newLocation = errorResponse.Headers["Location"];
+ if (!string.IsNullOrEmpty(newLocation))
+ {
+ uriString = newLocation;
+ return await CheckURLValidAsync(uriString); // Recursively check the new location
+ }
+ }
+ else
+ {
+ UpdateErrorMessage(statusCode);
+ }
+ return false;
+ }
+ else
+ {
+ // Handle other exceptions
+ return false;
+ }
}
if (response == null || response.StatusCode != HttpStatusCode.OK)
@@ -112,7 +138,17 @@ namespace Jellyfin.Views
}
}
+ // If everything is OK, update the URI before saving it
+ Central.Settings.JellyfinServer = uriString;
+
return true;
}
+
+
+ private void UpdateErrorMessage(int statusCode)
+ {
+ txtError.Visibility = Visibility.Visible;
+ txtError.Text = $"Error: {statusCode}";
+ }
}
-}
+}
\ No newline at end of file