How to implement an sample with Using ELSA with .net 8.0

I’m just learning ELSA. I’m analysing its documents. I found a example it is name is “Hello World HTTP”
I implemented that sample. But I couldn’t take any result.

I can compile this project. I will show details below.

ELSA Documents (The example in question can be found here) : https://v2.elsaworkflows.io/docs/quickstarts/hello-world-http

Project Detail

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Elsa.Activities.Http" Version="2.14.1" />
<PackageReference Include="Elsa.Core" Version="2.14.1" />
</ItemGroup>
</Project>
</code>
<code><Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net8.0</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> </PropertyGroup> <ItemGroup> <PackageReference Include="Elsa.Activities.Http" Version="2.14.1" /> <PackageReference Include="Elsa.Core" Version="2.14.1" /> </ItemGroup> </Project> </code>
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Elsa.Activities.Http" Version="2.14.1" />
    <PackageReference Include="Elsa.Core" Version="2.14.1" />
  </ItemGroup>

</Project>

Program.cs

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>using ElsaQuickstarts.WebApp.HelloWorld;
internal class Program
{
private static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddAuthorization();
builder.Services
.AddElsaCore(options => options
.AddHttpActivities()
.AddWorkflow<HelloWorld>());
var app = builder.Build();
app.UseRouting(); // Routing middleware
app.UseHttpActivities();
app.Run();
}
}
</code>
<code>using ElsaQuickstarts.WebApp.HelloWorld; internal class Program { private static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); builder.Services.AddAuthorization(); builder.Services .AddElsaCore(options => options .AddHttpActivities() .AddWorkflow<HelloWorld>()); var app = builder.Build(); app.UseRouting(); // Routing middleware app.UseHttpActivities(); app.Run(); } } </code>
using ElsaQuickstarts.WebApp.HelloWorld;

internal class Program
{
    private static void Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);

        builder.Services.AddAuthorization();
        builder.Services
                .AddElsaCore(options => options
                    .AddHttpActivities()
                    .AddWorkflow<HelloWorld>());

        var app = builder.Build();
        app.UseRouting(); // Routing middleware
        app.UseHttpActivities();
        app.Run();
    }
}

HelloWorld.cs

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>using System.Net;
using Elsa;
using Elsa.Activities.Http;
using Elsa.Builders;
namespace ElsaQuickstarts.WebApp.HelloWorld
{
/// <summary>
/// A workflow that is triggered when HTTP requests are made to /hello-world and writes a response.
/// </summary>
public class HelloWorld : IWorkflow
{
public void Build(IWorkflowBuilder builder)
{
builder
.HttpEndpoint("/hello-world") // Doğru endpoint tanımı
.WriteHttpResponse(HttpStatusCode.OK, "<h1>Hello World!</h1>", "text/html");
}
}
}
</code>
<code>using System.Net; using Elsa; using Elsa.Activities.Http; using Elsa.Builders; namespace ElsaQuickstarts.WebApp.HelloWorld { /// <summary> /// A workflow that is triggered when HTTP requests are made to /hello-world and writes a response. /// </summary> public class HelloWorld : IWorkflow { public void Build(IWorkflowBuilder builder) { builder .HttpEndpoint("/hello-world") // Doğru endpoint tanımı .WriteHttpResponse(HttpStatusCode.OK, "<h1>Hello World!</h1>", "text/html"); } } } </code>
using System.Net;
using Elsa;
using Elsa.Activities.Http;
using Elsa.Builders;

namespace ElsaQuickstarts.WebApp.HelloWorld
{
    /// <summary>
    /// A workflow that is triggered when HTTP requests are made to /hello-world and writes a response.
    /// </summary>
    public class HelloWorld : IWorkflow
    {
        public void Build(IWorkflowBuilder builder)
        {
           builder
                .HttpEndpoint("/hello-world") // Doğru endpoint tanımı
                .WriteHttpResponse(HttpStatusCode.OK, "<h1>Hello World!</h1>", "text/html");
        }
    }
}

I executed this command.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>PS C:Usersbarancan.gencsourcereposElsaQuickstarts.WebApp.HelloWorld> dotnet run --launch-profile https
</code>
<code>PS C:Usersbarancan.gencsourcereposElsaQuickstarts.WebApp.HelloWorld> dotnet run --launch-profile https </code>
PS C:Usersbarancan.gencsourcereposElsaQuickstarts.WebApp.HelloWorld> dotnet run --launch-profile https

I can see this output when I executed command.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>info: Microsoft.Hosting.Lifetime[14]
Now listening on: https://localhost:8005
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: C:Usersbarancan.gencsourcereposElsaQuickstarts.WebApp.HelloWorld
</code>
<code>info: Microsoft.Hosting.Lifetime[14] Now listening on: https://localhost:8005 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Development info: Microsoft.Hosting.Lifetime[0] Content root path: C:Usersbarancan.gencsourcereposElsaQuickstarts.WebApp.HelloWorld </code>
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://localhost:8005
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: C:Usersbarancan.gencsourcereposElsaQuickstarts.WebApp.HelloWorld

But when i requested this address https://localhost:8005/hello-world I get the following error.

404 Not Found Error Message

I did all what exactly the document saying. I built the project and I was able to run the project.
I expect the response to change when I go to the specified address. I’m trying to understand how works ELSA

How to implement an sample with Using ELSA with .net 8.0

To integrate the Elsa’s Workflow with .NET 8, You can read through and get started with this doc.

.csproj

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Elsa" Version="3.2.0" />
<PackageReference Include="Elsa.Http" Version="3.2.0" />
</ItemGroup>
</Project>
</code>
<code><Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net8.0</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> </PropertyGroup> <ItemGroup> <PackageReference Include="Elsa" Version="3.2.0" /> <PackageReference Include="Elsa.Http" Version="3.2.0" /> </ItemGroup> </Project> </code>
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Elsa" Version="3.2.0" />
    <PackageReference Include="Elsa.Http" Version="3.2.0" />
  </ItemGroup>

</Project>

workflow class with HTTP capabilities

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>public class HttpHelloWorld : WorkflowBase
{
protected override void Build(IWorkflowBuilder builder)
{
builder.Root = new Sequence
{
Activities =
{
new HttpEndpoint
{
Path = new("/hello-world"),
CanStartWorkflow = true
},
new WriteHttpResponse
{
Content = new("Hello world of HTTP workflows!")
}
}
};
}
}
</code>
<code>public class HttpHelloWorld : WorkflowBase { protected override void Build(IWorkflowBuilder builder) { builder.Root = new Sequence { Activities = { new HttpEndpoint { Path = new("/hello-world"), CanStartWorkflow = true }, new WriteHttpResponse { Content = new("Hello world of HTTP workflows!") } } }; } } </code>
public class HttpHelloWorld : WorkflowBase
{
    protected override void Build(IWorkflowBuilder builder)
    {
        builder.Root = new Sequence
        {
            Activities =
        {
            new HttpEndpoint
            {
                Path = new("/hello-world"),
                CanStartWorkflow = true
            },
            new WriteHttpResponse
            {
                Content = new("Hello world of HTTP workflows!")
            }
        }
        };
    }
}

program.cs

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>var builder = WebApplication.CreateBuilder(args);
builder.Services.AddElsa(elsa =>
{
elsa.AddWorkflow<HttpHelloWorld>();
elsa.UseHttp();
});
var app = builder.Build();
app.UseWorkflows();
app.Run();
</code>
<code>var builder = WebApplication.CreateBuilder(args); builder.Services.AddElsa(elsa => { elsa.AddWorkflow<HttpHelloWorld>(); elsa.UseHttp(); }); var app = builder.Build(); app.UseWorkflows(); app.Run(); </code>
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddElsa(elsa =>
{
    elsa.AddWorkflow<HttpHelloWorld>();
    elsa.UseHttp();
});

var app = builder.Build();

app.UseWorkflows();

app.Run();

Test Result

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật