Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check what URL a RedirectToRouteResult will make?

In my asp.net-mvc project I do a redirect from a post request to a get request.
In between my redirect and my arrival of the method I expect it to arrive, one of my parameters magically turns into null and I can't figure out why.
Probably it has something to do with my global.asax (route defenition).

The only way I can come up with to debug this is with the route debugger library. But I don't see how I can use it with a RedirectToRoute.
Any suggestions?

like image 772
Boris Callens Avatar asked Mar 20 '09 15:03

Boris Callens


2 Answers

A little late to the party but this was the first hit on Google for an issue I was having so thought I'd share my experience.

I wanted to parse a RedirectToRouteResult to a URL so I can redirect to it at a later stage, but this class has no method to do this. You can, however, use UrlHelper.RouteUrl(), e.g:

Url.RouteUrl(redirectResult.RouteName, redirectResult.RouteValues);

where Url is property of Controller class.

like image 178
eth0 Avatar answered Nov 15 '22 22:11

eth0


A redirect is a result sent to the browser, and then the browser honors the redirect by doing a GET on the new URL. Therefore, look at the browser to see what the URL is. When the browser receives the redirect, it will do a GET on the new URL, which you can see with Firebug, Fiddler, or the tool of your choice.

Inside the new action, when it is called, you can also examine Request.Url.

like image 20
Craig Stuntz Avatar answered Nov 15 '22 21:11

Craig Stuntz