Last post Nov 18, 2008 05:18 PM by Max Kukartsev
Nov 17, 2008 11:56 AM|asp_net4all|LINK
Hi need some help regarding page navigation.i have
http://localhost/default.aspx on address bar it should show http:/localhost/home.aspx and at the same time if i type
http://localhost/default.aspx it should give error saying page not found. i main target is to hide real file names of .net pages. if the user types the real names, should give error. only the fake names should
i would appreciate if a sample demo is provided or some helpfull links to solve this issue. even earlier my doubt was not cleared regarding loginview.
ASP.NET Request Filters
Asp.net 2.0 response filters
URL Rewriting in ASP.Net
Nov 18, 2008 12:32 PM|bgs264|LINK
You need to take care of this in global.asax.
In Application_BeginRequest, you can examine the address the user is trying to access.
If it is a "real page" (you could use system.io to see if the file exists), then you can do something like context.response.statuscode = 404, context.response.end.
If it is not a "real page", then you use URL Rewriting to rewrite the URL of the fake page to the URL of the real page. See "http://msdn.microsoft.com/en-us/library/ms972974.aspx" or google "url rewriting .net" for some info on this.
Nov 18, 2008 05:18 PM|Max Kukartsev|LINK
bgs264 is correct, and here's some additional info to his answer.
Only certain URLs ending with ".aspx" and ".ashx" (, etc...) are processed by ASP.NET, and if you want the fake URL change the extension to be something other than the default ones, or even without an extension, as to type in something like "http://localhost/MySite"
and have http://localhost/Default.aspx processed, then you need to add a "script mapping" with the target extension, or " * " (wildcard - any URLS including those without extension) to have ASP.NET handle them. Otherwise something like "http://localost/MySite.home"
will never even call ASP.NET with its Application_BeginRequest, and instead you'll get a 404 Not Found from IIS.
Hope this helps,