Answered by:
Is there any way to hide page name in url

Question
-
User-19205220 posted
In asp.net 4.0 Is there any way to hide page name in url
For example if I have 3 pages - page1.aspx, page2.aspx, page3.aspx in my domain www.abc.com is there any way to show like www.abc.com/anyenryptedvalue for www.abc.com/page1.aspx
like that if if redirect to next page www.abc.com/anyencrypedvalue for www.abc.com/page2.aspx or hide the page name
Thursday, December 19, 2019 6:39 AM
Answers
-
User-821857111 posted
You can use MapPageRoute to change the URL:
routes.MapPageRoute("SomeEncryptedValue", "~/page1.aspx");
routes.MapPageRoute("foo", "~/page2.aspx");
https://www.codeproject.com/Tips/698666/USE-OF-MapPageRoute-Method-IN-ASP-NET-WEBFORM-ROUT
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, December 19, 2019 6:49 AM
All replies
-
User-821857111 posted
You can use MapPageRoute to change the URL:
routes.MapPageRoute("SomeEncryptedValue", "~/page1.aspx");
routes.MapPageRoute("foo", "~/page2.aspx");
https://www.codeproject.com/Tips/698666/USE-OF-MapPageRoute-Method-IN-ASP-NET-WEBFORM-ROUT
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, December 19, 2019 6:49 AM -
User944797201 posted
I'd also do use the MapPageRoute and I strongly recommend you to have a look at the documentation too.
Thursday, December 19, 2019 7:49 AM -
User665608656 posted
Hi anupalavila,
If you want to hide or modify the name of the url, you can make the following changes in the webconfig file of your current project:
<?xml version="1.0"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="default.aspx Redirect" stopProcessing="true"> <match url="^(.*\/)*default\.aspx$" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_METHOD}" negate="true" pattern="^POST$" /> </conditions> <action type="Redirect" url="{R:1}" redirectType="Permanent"/> </rule> </rules> </rewrite> </system.webServer> </configuration>
For more details, you could refer to this link: https://stackoverflow.com/a/21598770
You can also refer to this article : URL Rewriting in ASP.NET
Best Regards,
YongQing.
Friday, December 20, 2019 9:07 AM