Simple Web Request
- Open Visual Studio as Administrator
- In Northwind project, create a new BussinessProcess named "WebDemo"
- Add the following to the class:
namespace Northwind
{
public class WebDemo : BusinessProcessBase
{
ENV.IO.WebWriter _ioRequester = new ENV.IO.WebWriter();
public WebDemo()
{
Streams.Add(_ioRequester);
}
public void Run()
{
Exit(ExitTiming.AfterRow);
Execute();
}
}
}
WebWriter
is an object that we use to work with the Web (Similar to Requester in Magic).
Streams
is an object which is used to transfer the data.
- In the OnStart, write a string back to the web page using the
WebWriter
namespace Northwind
{
public class WebDemo : BusinessProcessBase
{
ENV.IO.WebWriter _ioRequester = new ENV.IO.WebWriter();
public WebDemo()
{
Streams.Add(_ioRequester);
}
public void Run()
{
Exit(ExitTiming.AfterRow);
Execute();
}
protected override void OnStart()
{
_ioRequester.WriteLine("This is my first web page");
}
}
}
- In order to call this program from the web, it needs to have a unique identifier so we should create a public name for this program.
- Go to the
ApplicationPrograms.cs
and add a new entry as follows:
namespace Northwind
{
class ApplicationPrograms : ENV.ProgramCollection
{
public ApplicationPrograms()
{
Add(3, "Show Customers", "", typeof(ShowCustomers));
Add(4, "Show Products", "", typeof(ShowProducts));
Add(5, "Show Orders", "", typeof(ShowOrders));
Add(6, "Print - Order", "", typeof(Print_Order));
Add(7, "Print - Orders", "", typeof(Print_Orders));
Add("WebDemo", typeof(WebDemo));
}
}
}
Notice that the first parameter is the public name.
- Now, let’s configure the request URL.
Open the properties of the web project (Northwind.Server) and go to the "Web" tab.
The URL is a combination of Project Url option + Request.aspx?prgname=WebDemo (WebDemo is the unique public name and case sensitive) as follows:
http://localhost:61988/Request.aspx?prgname=WebDemo (Port number might be different in each computer)
- Set the Web Project as your startup project (Right-Click on the project ->'Set as StartUP Project')
- Build and run (click "Google Chrome" or "Internet Explorer")
Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com