FubuContinuation redirects

38 views
Skip to first unread message

RobertTheGrey

unread,
Feb 12, 2013, 12:19:51 PM2/12/13
to fubumv...@googlegroups.com
Hey guys,

What's the best way to redirect to a static html page?

For example, I've got FubuContinuation.RedirectTo("~/404.html") <-- deliberately kept simple in case there are numerous issues with infrastructure.

If I put the full URL in there, then it works fine, but it seems like the ~ is not being respected as the site root.

Is there a better way to do this instead? How do you guys deal with this?

P.S. I already have 404 working for "real" not found pages just using web.config and IIS of course, this is more like a "blog post not found" situation where the ID is not in the Database.

Thanks,
Rob

RobertTheGrey

unread,
Feb 12, 2013, 12:21:28 PM2/12/13
to fubumv...@googlegroups.com
Oh, I forgot to say that I can of course import the ICurrentHttpRequest into my class and build up the full URL from that, but that seems like overkill to me for something this simple?

Jeremy D. Miller

unread,
Feb 12, 2013, 12:48:13 PM2/12/13
to fubumv...@googlegroups.com
All I'm reading is "FubuContinuation.RedirectTo() has a small bug with how it handles literal url's"

Or actually, it's the ContinuationDirector that needs to be a touch smaller.  Can you log this?  I'd be happy to point you in the right direction for the pull request if you're feeling that way too….


--
You received this message because you are subscribed to the Google Groups "FubuMVC Development Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fubumvc-deve...@googlegroups.com.
To post to this group, send email to fubumv...@googlegroups.com.
Visit this group at http://groups.google.com/group/fubumvc-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

RobertTheGrey

unread,
Feb 12, 2013, 12:48:24 PM2/12/13
to fubumv...@googlegroups.com
Looks like it's gonna be one of those days...

I was messing around with too many options again and got my wires crossed. Looks like:
  • FubuContinuation.RedirectTo("~/404.html") <-- works just fine, respects the tilde
  • FubuContinuation.TransferTo("~/404.html") <-- falls over in a heap
Is the underlying reason for this that TransferTo is still trying to complete the run through the BahviorChain, whereas RedirectTo simply stops everything?

Or what am I missing?

The reason I want TransferTo, is that I'd like the user address bar to remain untouched so they can copy-paste broken URLs. I guess a better way would be to push 404 to an actual view and pass it the referring data to render on the page, but again, that's quite a lot of overkill just to get the previous URL. I guess I could also dig out the referrer URL from the headers with Javascript instead.

Feels like I'm doing it wrong...

Jeremy D. Miller

unread,
Feb 12, 2013, 1:04:22 PM2/12/13
to fubumv...@googlegroups.com
TransferTo() is NOT the equivalent to Server.Transfer() in the old ASP classic days (and I'm not the only one old enough here to remember that).  TransferTo is trying to find a FubuMVC endpoint in the model that takes a string as your input model, none probably exists, so it blows up.

RedirectTo() is issuing an Http 302 to that Url.


We can tackle this one of two ways, either enhance the ContinuationDirector to treat TransferTo(string) as write that file, or you build a partial that renders the 404 response and do a Transfer to that:

FubuContinuation.TransferTo(new Response404()) ???


Robert Greyling

unread,
Feb 12, 2013, 1:28:17 PM2/12/13
to fubumvc-devel
Thanks Jeremy,

Yes, in my head I was relating it back to Server.Transfer() hence the unexpected results. I think I'll go ahead and add a 404 view model with a corresponding spark view to get the benefits of keeping the URL static.

Out of curiosity, why do you say "build a partial"? Why not a full View? Can you transfer to a partial?

Thanks,
Rob

Joshua Arnold

unread,
Feb 12, 2013, 1:29:10 PM2/12/13
to fubumv...@googlegroups.com
He meant fubu partial

Gary Cox

unread,
Feb 12, 2013, 2:10:17 PM2/12/13
to fubumv...@googlegroups.com
Learned something new then, I also thought TransferTo was similar to Server.Transfer
Thank you,
Gary Cox

Jeremy D. Miller

unread,
Feb 12, 2013, 2:24:41 PM2/12/13
to fubumv...@googlegroups.com
Just so everyone knows, FubuContinuation.TransferTo() executes a fubu endpoint inline, so it's perfect for things like error handling pages or our equivalent to the PRG pattern in LoFi scenarios with FubuMVC.Validation

Matt S.

unread,
Feb 12, 2013, 3:54:07 PM2/12/13
to fubumv...@googlegroups.com
Well, that is nice! I was having classic ASP flashbacks too. :-P
He meant fubu partial
To unsubscribe from this group and stop receiving emails from it, send an email to fubumvc-devel+unsubscribe@googlegroups.com.

To post to this group, send email to fubumv...@googlegroups.com.
Visit this group at http://groups.google.com/group/fubumvc-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "FubuMVC Development Group" group.
To unsubscribe from this group and stop rec

--
You received this message because you are subscribed to the Google Groups "FubuMVC Development Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fubumvc-deve...@googlegroups.com.
To post to this group, send email to fubumv...@googlegroups.com.
Visit this group at http://groups.google.com/group/fubumvc-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Thank you,
Gary Cox

Ryan Rauh

unread,
Feb 12, 2013, 4:44:56 PM2/12/13
to FubuMVC Development Group
@Robert Do you still want the server to set the status code to 404? I think TransferTo will return a 200

-Ryan

Jeremy D. Miller

unread,
Feb 12, 2013, 4:48:35 PM2/12/13
to fubumv...@googlegroups.com
Ryan/Robert,

TransferTo() doesn't do anything to override the status code.  You can happily set the 404 status code on OutputWriter in whatever you're transfering to.
 
Jeremy D. Miller
The Shade Tree Developer
jeremy...@yahoo.com



From: Ryan Rauh <rauh...@gmail.com>
To: FubuMVC Development Group <fubumv...@googlegroups.com>
Sent: Tue, February 12, 2013 3:44:59 PM
Subject: Re: [fubumvc] FubuContinuation redirects

Robert Greyling

unread,
Feb 12, 2013, 4:49:36 PM2/12/13
to fubumvc-devel
Indeed it did return 200 - I set it manually to 404 instead.

thanks

Corey Kaylor

unread,
Feb 12, 2013, 4:50:25 PM2/12/13
to fubumv...@googlegroups.com
Nothing like accidentally having google show your error page text in search results.

Robert Greyling

unread,
Feb 12, 2013, 4:52:07 PM2/12/13
to fubumvc-devel
"happily set the 404 status code on OutputWriter" <-- And that is why Fubu kicks so much ass! :)

Ryan Rauh

unread,
Feb 12, 2013, 5:23:02 PM2/12/13
to FubuMVC Development Group
@Robert ... it almost like I've had to do the exact same thing once ;) or I'm psychic... I'll let you decide 

Peter Wetzel

unread,
Feb 12, 2013, 8:09:07 PM2/12/13
to fubumv...@googlegroups.com
Ah, the glory days of classic ASP... back when Internet Explorer was cutting edge and the internet was all-a-bubble.

Anyway, nice conversation; it gets the brain churning for various possibilities.
Reply all
Reply to author
Forward
0 new messages