.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Articles >> WWF >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Developing Sequential Workflow In ASP.Net Applications

Posted By:Sunil Yadav       Posted Date: May 27, 2010    Points: 25    Category: WWF    URL: http://www.dotnetspark.com  

In this article i am going to explain how to create sequential workflow in asp.net.

step:1 ->Create New Sequential Workflow Project

Open Visual Studio 2008 ->; create a new project->; Choose  Sequential Workflow Library

at this point,the workflow project contains single workflow class(workflow1).

step:2 ->  Drag a IfElse activity onto the design surface from  the toolbox.The designer looks like below figure below.

Note that while dragging activity on the surface you will see  green (+ sign) which indicates a place where you can drop activity.(you can also refer figure below).

step:3 -> Drop Code activity inside ifElseBranchActivity1 and ifElseBranchActivity2 and name them as Authorized and UnAuthorized respectively.

step:4 -> set the Condition on ifElseBranchActivity1 to  code condition and set the condition property to IsAuthorized.

private void IsAuthorized(object sender, ConditionalEventArgs e)
if (UserName == "sunil" && Password == "demo@123")
this.Result = "Welcome.aspx";
this.Result = "NotAuthorized.aspx";

Also create following to accept parameter value.

public string UserName { get; set; }
public string Password { get; set; }
public string Result { get; set; }

step:5 ->; Create asp.net application in the solution, add to more page Welcome.aspx and UnAuthorized.aspx i the application as shown below

Write down the following code on Login_Click.


protected void Login_Click(object sender, EventArgs e)
WorkflowRuntime wr = new WorkflowRuntime();

wr.AddService(new ManualWorkflowSchedulerService());
Dictionary parameters = new Dictionary();
parameters.Add("Result", "");
parameters.Add("UserName", txtUserName.Text);
parameters.Add("Password", txtPassword.Text);
wr.WorkflowCompleted += new EventHandler(wfRuntime_WorkflowCompleted);
WorkflowInstance wi = wr.CreateWorkflow(typeof(SequentialWorkflowDemo.Workflow1), parameters);
ManualWorkflowSchedulerService ss = wr.GetService();

also following line of code to redirect user to specific page.

void wfRuntime_WorkflowCompleted(object sender, WorkflowCompletedEventArgs e)

Your workflow application is ready to execute.Run your asp.net application.


 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend