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;
}
}
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;
}
}