Reputation: 1444
How can I pass two querysting parameters in URL routing using ASP.NET 4.0?
I have gone through many articles, but everywhere it shows only one parameter.
I'd like the display URL to be:
http://www.mywebsite.com/reports/1-this-is-my-first-report
The first parameter is ID: 1
The second is Name: This is my first report
I am trying following route, but it is not working
routes.MapPageRoute(
"MarketReports", // Route name
"Reports/{*i}-{*n}", // Route URL
"~/pageControl2.aspx" // Web page to handle route
);
How can I make this work as described?
Upvotes: 2
Views: 6878
Reputation: 169
Try this
Response.RedirectToRoute("UrlRouting for Querystring",
new { name = txtsearchurlrouting.Text, text = txtsearchid.Text });
In Global.asax
routes.MapPageRoute("UrlRouting for Querystring",
"Querystring/Selected/{name}/{text}/", "~/Address.aspx");
like this we can pass multiple querystring parameters
Upvotes: 1
Reputation: 50728
Try formatting the URL this way:
http://www.mywebsite.com/reports/1/this-is-my-first-report
routes.MapPageRoute(
"MarketReports", // Route name
"Reports/{*i}/{*n}", // Route URL
"~/pageControl2.aspx" // Web page to handle route
);
Upvotes: 3