elsa-core icon indicating copy to clipboard operation
elsa-core copied to clipboard

ASP.NET Core sample ElsaWeb cannot run successfully.

Open bullzhanghao opened this issue 9 months ago • 6 comments

Description

Created according to the sample requirements, the compilation has an error in the "elsa.UseHttp();" line and an error in "using Elsa.Workflows.Contracts;". After adding Elsa.Http and commenting "using Elsa.Workflows.Contracts;", it can be compiled, but 404 appears when outputting /hello-world in the browser. There are many problems with the sample, and even a simple sample cannot be compiled and run normally.

Steps to Reproduce

To help us identify the issue more quickly, please follow these guidelines:

  1. Detailed Steps: Provide a step-by-step description of what leads to the bug. Be as specific as possible. 1).create the Project Create a new empty ASP.NET app using the following command: dotnet new web -n "ElsaWeb"

    2).Add Packages Navigate to your project's root directory and install the Elsa package: cd ElsaWeb dotnet add package Elsa

    3).Modify Program.cs Open Program.cs in your project and replace its contents with the code provided below. using Elsa.Extensions; using ElsaWeb.Workflows;

    var builder = WebApplication.CreateBuilder(args);

    // Add services to the container. builder.Services.AddElsa(elsa => { elsa.AddWorkflow<HttpHelloWorld>(); elsa.UseHttp(); });

    var app = builder.Build();

    // Configure the HTTP request pipeline. app.UseWorkflows(); app.Run(); Add HttpHelloWorld Workflow

    4).Create a new directory called Workflows and add a new file to it called HttpHelloWorld.cs with the following. using Elsa.Http; using Elsa.Workflows; using Elsa.Workflows.Activities; using Elsa.Workflows.Contracts;

    namespace ElsaWeb.Workflows; 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!") } } }; } }

build error

The type or namespace name "Contracts" does not exist in the namespace "Elsa.Workflows" (are you missing an assembly reference?) The type or namespace name "Http" does not exist in the namespace "Elsa" (are you missing an assembly reference?) The type or namespace name "HttpEndpoint" could not be found (are you missing a using directive or assembly reference?) The type or namespace name "WriteHttpResponse" could not be found (are you missing a using directive or assembly reference?)

Environment

elsa 3.3.5, vs2022 ,net 8.0

run error

adding Elsa.Http package and commenting "using Elsa.Workflows.Contracts;", it can be compiled, but 404 appears when outputting /hello-world in the browser.

bullzhanghao avatar Mar 20 '25 07:03 bullzhanghao

ElsaWeb.zip

bullzhanghao avatar Mar 20 '25 07:03 bullzhanghao

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

// curl https://localhost:7092/workflows/hello-world

iamartinlong avatar Mar 27 '25 09:03 iamartinlong

Thanks for your reply. Unfortunately, it cannot be compiled due to syntax errors. Could you provide a simple Asp.Net sample project attachment that can be compiled and executed normally to demonstrate the availability of version 3.x? Thank you.

bullzhanghao avatar Mar 27 '25 13:03 bullzhanghao

am getting 404 too on elsa 3.3.5 using old startup.cs and dotnet 9

Isofteer avatar Apr 27 '25 19:04 Isofteer

I see, make sure the path is starts with the word workflow so its '/workflows/hello-world' if you are using the default setup from the documentation.

Isofteer avatar Apr 27 '25 20:04 Isofteer

@Isofteer were you able to resolve the contracts issue? I am also getting this:

error CS0234: The type or namespace name 'Contracts' does not exist in the namespace 'Elsa.Workflows' (are you missing an assembly reference?)

Following is my .csproj

<Project Sdk="Microsoft.NET.Sdk.Web">

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

  <ItemGroup>
    <PackageReference Include="Elsa" Version="3.3.5" />
    <PackageReference Include="Elsa.Http" Version="3.3.5" />
    <PackageReference Include="Elsa.Workflows.Core" Version="3.3.5" />
  </ItemGroup>

</Project>

ChucklesDroid avatar May 20 '25 12:05 ChucklesDroid