Home > DeveloperSection > Forums > ASP.NET 4.0 Url Routing
Simons Hood
Simons Hood

Total Post:70

Points:494
Posted on    December-03-2014 10:16 PM

 ASP.Net C#  Url Routing 
Ratings:


 1 Reply(s)
 529  View(s)
Rate this:

I am trying to use Rounting in ASP.NET 4.0

 

This is my code:(global.asax file)

 

    void Application_Start(object sender, EventArgs e)

    {

        RegisterRoutes(System.Web.Routing.RouteTable.Routes);

    }

 

    void RegisterRoutes(System.Web.Routing.RouteCollection routes)

    {

 

        routes.MapPageRoute("recordingDemo", "recording.aspx", "~/About.aspx?sub=recordingdemo");

    }

In About.aspx:

 

 if (Request.QueryString["sub"] != null)

 {

      switch (Request.QueryString["sub"].ToString())

      {

                    case "demo":

                        multiviewRecording.SetActiveView(viewDemo);

                        break;

      }

      ..........

}

The problem is that I don't have anymore querystring in About page.

 

What I want to do is: on link recording.aspx(this page doesn't exists in my page) I want to open the page About.aspx?sub=recordingdemo

 

It is possible to do something like this with Url Rounting?



Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Posted on    December-04-2014 7:30 AM

I found out the solution:

 routes.MapPageRoute("recordingDemo", "recording.aspx", "~/About.aspx?sub=recordingdemo",, true, new System.Web.Routing.RouteValueDictionary{{"sub", "demo"}});

And in About.aspx :

string route = Page.RouteData.Values["sub"].ToString();

I hope that my solution will help some other people.


Don't want to miss updates? Please click the below button!

Follow MindStick