Skip to content

Commit

Permalink
Fix deploy Umbraco as a child IIS application not working umbraco#11891
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Tkacul committed Dec 17, 2022
1 parent d5e1c73 commit 58649b1
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand All @@ -30,6 +29,7 @@
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Cms.Web.Common.Filters;
using Umbraco.Cms.Web.Common.Models;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Extensions;
using SignInResult = Microsoft.AspNetCore.Identity.SignInResult;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Web;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
Expand All @@ -13,7 +12,6 @@
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Mail;
using Umbraco.Cms.Core.Media;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Models.TemplateQuery;
using Umbraco.Cms.Core.Services;
Expand All @@ -27,6 +25,7 @@
using Umbraco.Cms.Web.BackOffice.Trees;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Cms.Web.Common.Models;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Extensions;

namespace Umbraco.Cms.Web.BackOffice.Controllers
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Web.BackOffice/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -35,6 +34,7 @@
using Umbraco.Cms.Web.Common.ActionsResults;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Cms.Web.Common.Authorization;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Cms.Web.Common.Security;
using Umbraco.Extensions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Routing;
using Umbraco.Cms.Core;
using Umbraco.Cms.Web.BackOffice.Install;

using Umbraco.Cms.Web.Common.Routing;
using Constants = Umbraco.Cms.Core.Constants;
namespace Umbraco.Extensions;

public static class BackofficeLinkGeneratorExtensions
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Web.BackOffice/Install/InstallAreaRoutes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Extensions;
using LinkGenerator = Umbraco.Cms.Web.Common.Routing.LinkGenerator;

namespace Umbraco.Cms.Web.BackOffice.Install;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Web.BackOffice.Controllers;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Extensions;

namespace Umbraco.Cms.Web.BackOffice.Install;
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Web.BackOffice/Install/InstallController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Umbraco.Cms.Core;
Expand All @@ -13,6 +12,7 @@
using Umbraco.Cms.Infrastructure.Install;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Cms.Web.Common.Filters;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Extensions;

namespace Umbraco.Cms.Web.BackOffice.Install;
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Web.BackOffice/Mapping/CommonTreeNodeMapper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Routing;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Web.BackOffice.Trees;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Extensions;

namespace Umbraco.Cms.Web.BackOffice.Mapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Routing;
using Umbraco.Cms.Web.Common.ModelsBuilder;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Extensions;

namespace Umbraco.Cms.Web.BackOffice.ModelsBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
using Umbraco.Cms.Web.Common.ModelBinders;
using Umbraco.Cms.Web.Common.Mvc;
using Umbraco.Cms.Web.Common.Profiler;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Cms.Web.Common.RuntimeMinification;
using Umbraco.Cms.Web.Common.Security;
using Umbraco.Cms.Web.Common.Templates;
Expand Down Expand Up @@ -168,7 +169,7 @@ public static IUmbracoBuilder AddUmbracoCore(this IUmbracoBuilder builder)
builder.Services.AddUnique<IUmbracoApplicationLifetime, AspNetCoreUmbracoApplicationLifetime>();
builder.Services.AddUnique<IApplicationShutdownRegistry, AspNetCoreApplicationShutdownRegistry>();
builder.Services.AddTransient<IIpAddressUtilities, IpAddressUtilities>();

builder.Services.AddSingleton<LinkGenerator, LinkGenerator>();
return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
using System.Linq.Expressions;
using System.Reflection;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Core.Web.Mvc;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Cms.Web.Common.Routing;

namespace Umbraco.Extensions;

Expand Down
64 changes: 64 additions & 0 deletions src/Umbraco.Web.Common/Routing/LinkGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Umbraco.Cms.Core.Hosting;

namespace Umbraco.Cms.Web.Common.Routing;

/// <summary>
/// Umbraco LinkGenerator. Generates Links with path, when no path is given.
/// </summary>
public class LinkGenerator
{
private readonly Microsoft.AspNetCore.Routing.LinkGenerator _linkGenerator;
private readonly string _pathBase;

/// <summary>
/// Initialize Umbraco LinkGenerator
/// </summary>
/// <param name="linkGenerator"></param>
/// <param name="hostingEnvironment"></param>
public LinkGenerator(Microsoft.AspNetCore.Routing.LinkGenerator linkGenerator, IHostingEnvironment hostingEnvironment)
{
_linkGenerator = linkGenerator;
_pathBase = hostingEnvironment.ApplicationVirtualPath;
}

public string? GetPathByAddress<TAddress>(
HttpContext httpContext,
TAddress address,
RouteValueDictionary values,
RouteValueDictionary? ambientValues = null,
PathString? pathBase = null,
FragmentString fragment = new FragmentString(),
LinkOptions? options = null)
{
pathBase ??= _pathBase;
return _linkGenerator.GetPathByAddress(httpContext, address, values, ambientValues, pathBase, fragment, options);
}

public string? GetPathByAddress<TAddress>(TAddress address, RouteValueDictionary values,
PathString pathBase = new PathString(), FragmentString fragment = new FragmentString(),
LinkOptions? options = null)
{
pathBase = string.IsNullOrWhiteSpace(pathBase.Value) ? new PathString(_pathBase) : pathBase;
return _linkGenerator.GetPathByAddress(address, values, pathBase, fragment, options);
}

public string? GetUriByAddress<TAddress>(HttpContext httpContext, TAddress address, RouteValueDictionary values,
RouteValueDictionary? ambientValues = null, string? scheme = null, HostString? host = null,
PathString? pathBase = null, FragmentString fragment = new FragmentString(), LinkOptions? options = null)
{
pathBase ??= _pathBase;
return _linkGenerator.GetUriByAddress(httpContext, address, values, ambientValues, scheme, host, pathBase, fragment, options);
}

public string? GetUriByAddress<TAddress>(TAddress address, RouteValueDictionary values, string? scheme, HostString host,
PathString pathBase = new PathString(), FragmentString fragment = new FragmentString(),
LinkOptions? options = null)
{
pathBase = string.IsNullOrWhiteSpace(pathBase.Value) ? new PathString(_pathBase) : pathBase;
return _linkGenerator.GetUriByAddress(address, values, scheme, host, pathBase, fragment, options);
}

public string? GetPathByAction(string action, string controllerName, object values) => _linkGenerator.GetPathByAction(action, controllerName, values, _pathBase);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using System.Reflection;
using Microsoft.AspNetCore.Routing;
using Umbraco.Cms.Core;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Cms.Web.Website.Controllers;

namespace Umbraco.Extensions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -25,6 +24,7 @@
using Umbraco.Cms.Tests.Integration.Testing;
using Umbraco.Cms.Web.BackOffice.Controllers;
using Umbraco.Cms.Web.Common.Controllers;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Cms.Web.Website.Controllers;

namespace Umbraco.Cms.Tests.Integration.TestServerTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using AutoFixture.NUnit3;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -39,6 +38,7 @@
using Umbraco.Cms.Web.BackOffice.Controllers;
using Umbraco.Cms.Web.BackOffice.Mapping;
using Umbraco.Cms.Web.Common.ActionsResults;
using Umbraco.Cms.Web.Common.Routing;
using Umbraco.Cms.Web.Common.Security;
using MemberMapDefinition = Umbraco.Cms.Web.BackOffice.Mapping.MemberMapDefinition;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.

using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Moq;
Expand All @@ -12,6 +11,7 @@
using Umbraco.Cms.Web.BackOffice.Install;
using Umbraco.Extensions;
using static Umbraco.Cms.Core.Constants.Web.Routing;
using LinkGenerator = Umbraco.Cms.Web.Common.Routing.LinkGenerator;

namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.Common.Routing;

Expand Down

0 comments on commit 58649b1

Please sign in to comment.