summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-05-14 19:25:51 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-05-14 19:25:51 -0400
commit896f531f4f6fc7f0e8dfcfc0d6433850233ee749 (patch)
treebfb91a61a7cb141f5a4d3f5ff9ec565d64377b2d
parentb2334fda1611efcfb2f9e48bd82e481e03bd9095 (diff)
downloadSMAPI-896f531f4f6fc7f0e8dfcfc0d6433850233ee749.tar.gz
SMAPI-896f531f4f6fc7f0e8dfcfc0d6433850233ee749.tar.bz2
SMAPI-896f531f4f6fc7f0e8dfcfc0d6433850233ee749.zip
fix broken action links after update to .NET Core 3.0
-rw-r--r--src/SMAPI.Web/Framework/Extensions.cs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/SMAPI.Web/Framework/Extensions.cs b/src/SMAPI.Web/Framework/Extensions.cs
index 96463233..ad7e645a 100644
--- a/src/SMAPI.Web/Framework/Extensions.cs
+++ b/src/SMAPI.Web/Framework/Extensions.cs
@@ -22,6 +22,7 @@ namespace StardewModdingAPI.Web.Framework
/// <returns>The generated URL.</returns>
public static string PlainAction(this IUrlHelper helper, [AspMvcAction] string action, [AspMvcController] string controller, object values = null, bool absoluteUrl = false)
{
+ // get route values
RouteValueDictionary valuesDict = new RouteValueDictionary(values);
foreach (var value in helper.ActionContext.RouteData.Values)
{
@@ -29,13 +30,19 @@ namespace StardewModdingAPI.Web.Framework
valuesDict[value.Key] = null; // explicitly remove it from the URL
}
+ // get relative URL
string url = helper.Action(action, controller, valuesDict);
+ if (url == null && action.EndsWith("Async"))
+ url = helper.Action(action[..^"Async".Length], controller, valuesDict);
+
+ // get absolute URL
if (absoluteUrl)
{
HttpRequest request = helper.ActionContext.HttpContext.Request;
Uri baseUri = new Uri($"{request.Scheme}://{request.Host}");
url = new Uri(baseUri, url).ToString();
}
+
return url;
}