Manual Route Manipulation

  • Thread starter Thread starter Brian Roberds
  • Start date Start date
B

Brian Roberds

I'm trying to create a routing change in a regular ASP.net web
application w/o using MVC. I'm just getting started learning the
routing information made available now. The documentation and
community papers about this are sparse so I'm just diving in.

Can anybody tell me if this is even doable, and if so what is wrong
with what I have done? Is there a good way to Debug something like
this?

I'm using this in my Global.asax:

void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(RouteTable.Routes);
}

public static void RegisterRoutes(RouteCollection routes)
{
routes.Add(new Route("coolspot/{coolspotid}", new
CoolSpotRouteHandler()));
}

public class CoolSpotRouteHandler : IRouteHandler
{
public IHttpHandler GetHttpHandler(RequestContext
requestContext)
{
string TheID = (string)requestContext.RouteData.Values
["coolspotid"];
requestContext.HttpContext.Response.Redirect("http://
www.google.com?cs=" + TheID);
return null;
}
}
 
Brian Roberds said:
I'm trying to create a routing change in a regular ASP.net web
application w/o using MVC. I'm just getting started learning the
routing information made available now. The documentation and
community papers about this are sparse so I'm just diving in.

Can anybody tell me if this is even doable, and if so what is wrong
with what I have done? Is there a good way to Debug something like
this?

AFAIK, you can't Response.Redirect in the controller in the manner you have
here. You can set it up something like this question on Stack Overflow:
http://tinyurl.com/yfg4x9k

--
Peace and Grace,
Greg

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

************************************************
| Think outside the box! |
************************************************
 
Back
Top