1

I use ASP.NET Routing for pretty URLs, but I cant access QueryStringParameters (only RouteData value). I am using the routing with Web Forms.

Here is example of my RegisterRoutes (Global.asax):

routes.MapPageRoute("Catalog", "{language}/catalog/", "~/Pages/Catalog.aspx?step=1");

I use this code for accessing parameter "step" in Catalog.aspx page:

string value = Request.QueryString["step"];

But it returns null.

How can I access QueryString parameter "step" if I don't want toget it from RouteData?

mason
  • 31,774
  • 10
  • 77
  • 121
Earlgray
  • 647
  • 1
  • 8
  • 31

1 Answers1

0

Use GetFreindlyURLSegement. You may need to get the NuGet package (if you do not have it already) Micorsoft.AspNet.FriendlyURLs

var Segment = Request.GetFriendlyUrlSegments().ToList();
if (Segment.Count <= 0)
{
    return;
}

string param1 = Segment[0].ToString();
string param2 = Segment[1].ToString();
Elim Garak
  • 1,728
  • 1
  • 16
  • 21