Quick Nav:  Online Store   |   Login | Register

Using Conditional Rules

Rate this topic:

Please Register to post a reply. Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.
AuthorMessages
John Mitchell
Posts:3033


05/01/2008 4:59 PM  

Using Conditional Rules

A conditional rule basically consists of a special function type of PageBlaster token syntax that allows an IF condition to be evaluated before executing the rules that it contains.  The syntax of an IF function is as follows:

[PB: IF(expression1 evaloperator expression2 )  {true condition }else{false condition} ]

Where:

expression1: can be a literal term or the result of an inner function
   Inner functions are:  
                        Match ( expression1, expresion2 )  where expression2 can use regular expressions
                        Len (expresion1)
                        Left (expresion1,length)
                        Right (expresion1,length)
                        Substring(expresion1, start, length)

evaloperator: can be any of the following operators:   =, == , != , <> , >=, <=, <, >
    equals, not equals, greater than or equal to, less than or equal to, less than, greater than

expression2: same as expression 1

Expressions can be literal or you can use PB: tokens
The condition statements are enclosed in curly braces
The eval operator and expression are optional if you are using an inner function that evaluates to true or false.
The else part with the false condition is optional

So an example conditional statement that could be used to match on a Url and do a 301 redirect would look like this:

[PB: IF(  Match("[PB:Request.Url]","http://snapsis.com")  ) {

     [PB: Response.Status("301 Moved Permanently") ]

     [PB: Response.AddHeader("Location","http://www.snapsis.com") ]

     [PB: Response.End() ]

} ]

Dean
<20 Posts
Posts:2


06/26/2008 8:56 AM  
When I use [PB: Response.End() ] it is VERY slow to respond and I get the following error:

Cannot access a closed Stream.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ObjectDisposedException: Cannot access a closed Stream.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[ObjectDisposedException: Cannot access a closed Stream.]
System.IO.__Error.StreamIsClosed() +56
System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count) +2845460
System.Web.HttpWriter.Filter(Boolean finalFiltering) +251
System.Web.HttpResponse.FilterOutput() +97
System.Web.ApplicationStepManager.ResumeSteps(Exception error) +564
System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +141
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +436




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

WHAT AM I DOING WRONG?
John Mitchell
Posts:3033


06/26/2008 9:36 AM  
Hi Dean,
I haven't experienced the behavior you are describing, so I need to find out if something is different in how you are using it.
Are you using Response.End() with a response header change like in the example, or for something else?

What happens if you just leave that part off? It should still work without the Response.End()
You can also try using Response.Clear() right before the Response.End()
Dean
<20 Posts
Posts:2


06/26/2008 6:49 PM  

It is the same erro with the [PB: Response.Clear() ]...

It does seem to work w/o the Resonse.End, but seems very slow to handle each request.

John Mitchell
Posts:3033


06/26/2008 8:40 PM  
I'm almost finished with a new enhancement that may help speed things up.

If you are interested in trying it out let me know.
Please Register to post a reply. Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.
Forums >Snapsis Product Support >PageBlaster > Using Conditional Rules



ActiveForums 3.7
Powered by: Snapsis Software