Need to mapped route eg http://localhost:53244/page.aspx?ID=7842 to http://localhost:53244/Home and need to pass default query string in new maped URL
i have already tried System.Web.Routing.RouteTable.Routes.MapPageRoute("Home", "Home", "~/Page.aspx", false, new RouteValueDictionary { { "ID", "7844" } });
but its not working for me because i need id in request.querystring not in Page.RouteData.Values["ID"]
This is my basic code System.Web.Routing.RouteTable.Routes.MapPageRoute("Home", "Home/{*queryvalues}", "~/Page.aspx", false);
in which i can use url like http://localhost:53244/Home?ID=7842 but i need only http://localhost:53244/Home
Using Web.Config you can use URL mapping
<system.web>
<urlMappings enabled="true">
<add
url="~/page.aspx?ID=.."
mappedUrl="~/Home" />
</system.web>
For more info check this
To handle all pages that the page.aspx return you can use url rewriting rules
<rewriteModule>
<rewriteOn>true</rewriteOn>
<rewriteRules>
<rule source="(.*)/Home"
destination="page.aspx?ID=$1"/>
</rewriteRules>
</rewriteModule>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.