Skip to main content

Posts

Workflow Foundation 4 - Part 2 - Executing workflows

In my introductory post I had focused on giving a brief overview of workflow foundation-4 highlighting what is new and how things have changed from 3.5 to 4. You can check this out here . This post will be a very simple one in which I am going to focus on how to execute workflows. Executing workflows is very simple in WF4. There are basically two approaches - Use WorkflowInvoker Use WorkflowApplication Using WorkflowInvoker is the simplest of the two approaches. Some of the disadvantages of this method are - You cannot persist the workflow instance You cannot unload or resume bookmarks You can execute the workflow synchronously or asynchronously both using WorkflowInvoker. To execute the workflow synchronously using the WorkflowInvoker you simply call its static method Invoke and pass the workflow object to it. Here is a simple example - Sequence seqWorkflow = new Sequence { Activities = { new WriteLine {Text = "Hello"}, new WriteLine {Text = "World using WorkflowInvoker...

Invalid Viewstate Problem

Recently I have been facing this problem of invalid viewstate. After googling a bit found some interesting concepts and solutions related to viewstate. So I thought let me just make a note of these references and have them handy. This is from the Microsoft Support highlihgting some techniques that you can use to debug / troubleshoot this problem - http://support.microsoft.com/?id=829743 This one is more interesting which highlights how you can get this problem while using Server.Transfer method, again from Microsoft Support - http://support.microsoft.com/kb/316920/ This one here is related to machineKey set to auto generate in machine.config http://forums.asp.net/p/1059371/1516632.aspx This one here is related to third party web site (running on different framework version) posting into your web site. http://blogs.msdn.com/tess/archive/2007/06/11/a-case-of-invalid-viewstate.aspx Hope all your invalid viewstate problems get taken care of with this. Here is the exception detail - Excepti...

Introduction to Workflow Foundation 4 (WF4)

I finally decided to pick-up my blogging once more. Since I have been trying to learn Windows Workflow Foundation 4 (WF4) I thought I might as well start off with this topic. WF4 is a development framework that enables you to create a workflow and embed it in a .Net application. It is neither an executable application nor a language. It provides a set of tools for declaring a workflow, activities to create your logic and to define control flow and a runtime for executing the resulting application definition. It also provides services for persistence of state, tracking and bookmarking. You can create your workflow directly in code, in mark-up or in a combination of both. Workflow provide us with two major advantages - Creating unified application logic. Making application logic scalable. Workflow Authoring styles - Sequential Workflow executes a set of contained activities in a sequential manner. Workflow Foundation was introduced in the .Net 3.0 and updated in 3.5. In .net 4 it has bee...

How to call web service in javascript using ASP.Net AJAX?

I wanted to call a web service that is internal to my asp.net web site project in my javascript code and I wanted to call it using the ASP.Net AJAX instead of the usual XMLHttpRequest stuff. So here is what I found. In-order to acheive this lets create a simple web site project and add a very basic service. Lets name it as HelloService (HelloService.asmx). Add a simple web method GetMessage which will accept an integer input and return a string type.  Your HelloService.asmx.cs should look like this. using System.Web.Script.Services; namespace MyServices {     [WebService(Namespace = "http://tempuri.org/")]     [WebServiceBinding(ConformsTo =      WsiProfiles.BasicProfile1_1)]         // To allow this Web Service to be called from script,     // using ASP.NET AJAX.     [ScriptService]         public class HelloService : Syste...

How to use a custom config file?

Recently I was wondering how to use custom configuration files in my application. So here it is all about custom configuration file First of all let me clarify what I mean by custom configuration files? For me it was simply about using customfile.config instead of the usual app.config and or web.config. In-order to use customfile.config instead of app.config in an application lets create a simple console application. After you have created a simple console application right click the project in solution explorer window and click add new item. From the list of options available select the Application Configuration File. Now rename the app.config name to customfile.config and click ok. Open the customfile.config. <?xml version="1.0" encoding="utf-8" ?> <configuration> </configuration> Lets add some configuration elements that are most common to our config files. <?xml version="1.0" encoding="utf-8" ?> ...

URL Rewriting

When I first ventured into this topic I thought this would be pretty straight forward but then being in software field I should have known better. Nothing is as simple as it sounds. So here we go URL re-writing in ASP.Net. What URL re-writing means is that you intercept an incoming web request in your web application and then redirect the web request to a different web resource in your web application. Now this is not done simply using Response.Redirect or Server.Redirect. There are many reasons why you would choose to do URL re-writing and the major ones could be - You want your urls to be search engine friendly. Your website has undergone restructuring or you expect the folders to be moved arround later. You want your urls to be user friendly (as in easier to remember). Any web request when it enters the ASP.Net engine an HTTPContext object is created and assigned to it and then it goes through a series of HTTPModules finally hitting a HTTPHandler. The HTTPContext object provides a m...

When to use Viewstate, Session, and Cache?

ViewState is used to manage asp.net server side controls state accross page postbacks. We can always store our own custom information into the viewstate. While storing custom information note should be made of the size of the viewstate as it impacts the page rendering time at the client end. Session is used to manage information for a particular user session. Any information that is needed with in a particular user's session can be stored here. Caching is used in asp.net to store objects in memory that require extensive server resources to create. You can establish an expiration policy with this. As a general rule of thumb - You use ViewState to store small amounts of data that is needed within the same page. You use Session to store data that is needed within the same user session. You can use data caching to store data that is needed accross user sessions through out the application.