Re: Mavnet-user digest, Vol 1 #118 - 7 msgs
Aaron Clauson <aza_rc <at> yahoo.com>
2004-02-20 10:38:50 GMT
>Message: 4
>Date: Wed, 11 Feb 2004 15:15:49 +0200
>From: Ihor Bobak <ibobak <at> ukeess.com>
>Organization: UKEESS Software House
>To: mavnet-user <at> lists.sourceforge.net
>Subject: [Mavnet-user] Docs needed
>Reply-To: mavnet-user <at> lists.sourceforge.net
>
>Dear all,
>
>I am searching for a normal documentation for
>Maverick.NET.
>Does there exist any?
>
>Please, do not propose to see the manual on
>http://mavnet.sourceforge.net/, since it is
absolutely
>useless for beginners.
>
>Thanks in advance.
>
>Best regards,
> Ihor.
While I don't have any documentation to add I have put
some examples/samples for using Maverick.Net at:
http://azaclauson.com/Maverick/MaverickWebApps/samples.aspx
Although you should be aware that these are not
particularly verbose and were designed more as a quick
code
reference then a user guide.
Aaron
>Message: 5
>From: Braswell Paul <Paul.Braswell <at> eHC.com>
>To: "'mavnet-user <at> lists.sourceforge.net'"
> <mavnet-user <at> lists.sourceforge.net>
>Date: Fri, 13 Feb 2004 10:48:55 -0600
>Subject: [Mavnet-user] Problems in Inheriting Page
from
>Maverick.Ctl.Aspx.ControllablePa
> ge
>Reply-To: mavnet-user <at> lists.sourceforge.net
>
>
>I'm facing a similar problem as listed below. For a
simple test case I
>changed maverick.config in the Calendar application
to the following
>and
>returned "error" from Default.aspx:
>
><?xml version="1.0"?>
>
><maverick version="2.0" default-view-type="document"
>default-transform-type="document">
> <commands>
> <command name="Default.aspx">
> <view name="success" type="trivial">
> <transform path="~/Wrapper.aspx"/>
> </view>
> <view name="april" path="~/April.aspx">
> <transform path="~/Wrapper.aspx"/>
> </view>
> <view name="button" path="~/Button.aspx">
> <transform path="~/Wrapper.aspx"/>
> </view>
> <view name="error" path="~/Foo/Default.aspx">
> <transform path="~/Wrapper.aspx"/>
> </view>
> </command>
>
> <command name="Foo/Default.aspx">
> <view name="success" type="trivial">
> <transform path="~/Wrapper.aspx"/>
> </view>
> <view name="april" path="~/Foo/December.aspx">
> <transform path="~/Wrapper.aspx"/>
> </view>
> <view name="button" path="~/Button.aspx">
> <transform path="~/Wrapper.aspx"/>
> </view>
> </command>
> </commands>
></maverick>
>
>
>I get the same error as Rocky: OutputStream is not
available when a
>custom
>TextWriter is used.
>
>Is this a bug or am I missing something? If this is
not a bug, how do
>I
>redirect to another controller?
>
>Thanks in advance.
>
>Paul
The quick answer is to use the redirect view, e.g.,
<view name="error" type="redirect"
path="~/Foo/Default.aspx" >
The long answer is:
In the view processing stage for a document view
(DispatchedViewFactory.cs) the following code is used,
vctx.HttpContext.Server.Execute(path, output);
This line while seeming fairly straight forward,
simply calling another web page and placing the
results into the
output stream, seems to be causing a few problems. One
problem I have already encountered is that xml files
are
returned as invalid xml due to some extra characters
at the start of the stream (this could have been the
content
encoding but I didn't track it down further,
preferring to load the file directly).
In your case the problem appears to be more
complicated. Before I go into it I should just say
that the
integration between ASP.Net and Maverick.Net is a bit
confusing and while the solution in the Maverick.Net
framework is a good one that generally works it is
probably not the best way to do things. ASP.Net and
Maverick.Net are two different approaches to web
application work flow, ASP.Net being a page controller
and
Maverick being a front controller, any integration
between the two is therefore going to be slightly
"messy". See
http://azaclauson.com/Maverick/models/theMavAspQuandary.htm
for a fuller discussion.
Anyway back to the problem of redirecting to another
Maverick controller. From debugging through the code
it looks
as if the problem is deriving from the way ASP.Net
processes the Server.Execute commands. The first time
Maverick
sees the command after ASP.Net has finished with it is
in the ControllablePage class and the Render method -
this
is normally where ASP.Net writes to the Http Output
stream but in this case has been redirected to a
string buffer
- as shown below.
protected sealed override void Render(HtmlTextWriter
writer)
{
AspxController controller = new AspxController();
controller.Render(this, Context);
}
Once again this seems fairly innocous. For Maverick
ASP.Net commands it works fine; however when a
Server.Redirect
occcurs in a Maverick view the Context - being the
HttpConext object for the whole Http request/response
page
processing - appears to be from the page calling
Server.Execute and NOT from the page being called. So
the flow is going like this,
Simplified config,
<commands>
<command name="Default.aspx">
<view name="error" path="~/Foo/Default.aspx">
<transform path="~/Wrapper.aspx"/>
</view>
</command>
<command name="Foo/Default.aspx">
<view name="success" type="trivial">
<transform path="~/Wrapper.aspx"/>
</view>
</command>
</commands>
1. Request for Default.aspx received by ASP.Net
PageHandlerFactory,
2. ASP.Net finishes processing Default.aspx and
invokes the Maverick.Net AspxController object,
3. The AspxController extracts the command name from
the HttpContext and processes the view stage for that
command,
4. View stage calls Server.Execute for
Foo/Default.aspx,
5. Request for Foo/Default.aspx received by ASP.Net
PageHandlerFactory,
Everything is fine to here (although I did get an
error about inserting duplicate models into the
Context.Items that I ahd to get around, don't know why
you didn't get this as well) but now when the
AspxController is invoked the HttpContext for the
original page, Default.aspx, and NOT the current page,
Foo/Default.aspx, is passed across.
6. ASP.Net finishes processing Foo/Default.aspx and
invokes the Maverick.Net AspxController object,
Exception is thrown when the original page,
Default.aspx, attempts to write to the
HttpResponse.OutputStream, I suspect this is because
the second page changed the stream and the original
page has an invalid stream although I am not sure. The
point is though that even if the original page could
write to the output stream it would be incorrect since
Maverick thinks it's processing the first command when
it's actually doing the second one.
I imagine that's all very confusing. Perhaps an easier
way to see this working is to look at the log file.
What you will see is,
Maverick.Ctl.Aspx.AspxController [] - Servicing
command: Default.aspx
Maverick.Ctl.Aspx.AspxController [] - Servicing
command: Default.aspx
What you should see is,
Maverick.Ctl.Aspx.AspxController [] - Servicing
command: Default.aspx
Maverick.Ctl.Aspx.AspxController [] - Servicing
command: Foo/Default.aspx
Hope that helps more than hinders.
Aaron
__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click