Manual Route Manipulation

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

Gregory A. Beamer

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! |
************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top