Manual Route Manipulation

Discussion in 'ASP .Net' started by Brian Roberds, Jan 24, 2010.

  1. 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, Jan 24, 2010
    #1
    1. Advertising

  2. "Brian Roberds" <> wrote in message
    news:...
    > 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! |
    ************************************************
    Gregory A. Beamer, Jan 25, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sridhar Hegde
    Replies:
    2
    Views:
    2,504
    Ajeetha Kumari
    Sep 13, 2004
  2. Divyang M
    Replies:
    2
    Views:
    741
    Divyang M
    May 26, 2005
  3. Replies:
    2
    Views:
    853
    Mike Treseler
    Sep 23, 2005
  4. paul reed

    Re-route to selected default page

    paul reed, Feb 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    400
    Fred Nelson
    Feb 25, 2004
  5. Bob
    Replies:
    1
    Views:
    318
    =?Utf-8?B?cm9iZXJ0?=
    May 27, 2004
Loading...

Share This Page