You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在现有Umbraco网站中部署独立自定义应用的技术问询

Alright, let's walk through how to build that fully independent custom app alongside your existing Umbraco site—starting with the preferred same-host deployment, then covering the subdomain fallback if that doesn't fit your needs.

Same-Host Deployment (Preferred Approach)

Since you want to keep everything on the same host, leveraging Umbraco's underlying ASP.NET framework is the cleanest way to isolate your app while sharing server resources.

Step 1: Add a dedicated Area for your custom app

Umbraco uses ASP.NET MVC/Razor Pages, so creating an Area lets you completely separate your app's controllers, views, and business logic from the main Umbraco content. Here's how to set it up:

  • Right-click your Umbraco project in Visual Studio → Add → Area. Name it something unique like CustomApp (avoid reserved names like "umbraco" or "admin").
  • Configure custom routes for your Area that bypass Umbraco's routing:
    • For Umbraco 8 and earlier (.NET Framework), edit the Area's RouteConfig.cs to define your route, and make sure AreaRegistration.RegisterAllAreas(); runs before Umbraco's route registration in Global.asax.cs. Example route:
      public static void RegisterRoutes(RouteCollection routes)
      {
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
      
          routes.MapRoute(
              name: "CustomApp_Default",
              url: "custom-app/{controller}/{action}/{id}",
              defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
              namespaces: new[] { "YourProject.Areas.CustomApp.Controllers" }
          );
      }
      
    • For Umbraco 9+ (.NET Core), register the Area route in Program.cs before Umbraco's endpoint mappings:
      app.UseEndpoints(endpoints =>
      {
          // Your custom app route first
          endpoints.MapAreaControllerRoute(
              name: "CustomApp",
              areaName: "CustomApp",
              pattern: "custom-app/{controller=Home}/{action=Index}/{id?}"
          );
      
          // Umbraco's routes come next
          endpoints.MapUmbraco();
      });
      

Step 2: Isolate your app's functionality

  • Keep all models, services, and business logic within the Area's folder structure. Avoid referencing Umbraco core services unless you explicitly need to (this keeps your app truly independent).
  • Use a separate layout file for your custom app's views to ensure its UI is completely disconnected from the main Umbraco site. You can create a _Layout.cshtml in the Area's Views/Shared folder and reference it in your app's views.

If your app needs authentication, you have two options:

  • Use ASP.NET Identity independently of Umbraco's membership system for full isolation.
  • Integrate with Umbraco's user accounts if you want shared login, but configure authentication middleware specifically for your Area's routes to avoid affecting the main site.
Subdomain Deployment (Fallback Option)

If same-host deployment isn't feasible (e.g., strict isolation requirements, conflicting dependencies), go with a standalone app on a subdomain:

Step 1: Build a separate ASP.NET project

Create a new standalone ASP.NET MVC/Razor Pages project—no need to reference Umbraco at all. This gives you full control over dependencies, routing, and security, ensuring your app is 100% independent.

Step 2: Configure subdomain hosting

  • In your hosting provider's control panel, set up a subdomain (e.g., app.yourdomain.com) pointing to your new app's deployment directory.
  • Host both the main Umbraco site and subdomain app on the same server if you want to share infrastructure, but use a separate database for the custom app to maintain full independence.

Step 3: Shared resources (if needed)

If you must share data between the two apps (like user accounts), use a shared database with separate schemas, or build a lightweight API in one app that the other consumes. Keep this integration minimal to preserve your app's independence.

Quick Tips
  • Test routing thoroughly: For same-host deployment, verify your custom app routes (e.g., yourdomain.com/custom-app/home) don't redirect to Umbraco's 404 or content pages. If they do, double-check that your Area routes are registered before Umbraco's.
  • Deployment best practices: For same-host, include the Area files in your regular Umbraco deployment package. For subdomain, deploy the app as a separate site in IIS (or your hosting platform) with its own application pool.

内容的提问来源于stack exchange,提问作者Armand

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:32:27