Asked by:
Serve extensionless URL

Question
-
User-711996264 posted
I am trying to have profile pages on a website which are dynamic pages. The url needs to be mydomainname.com/username format and this take them to profiles.aspx?username where i can show the information for that user. The url needs to remain as mydomainname.com/username for search engines and to look more professional. I have looked at using application_begeinrequest in global file, but i cant seem to get this to work properly. I am also open for a better way to do the same. Any ideas or help you can offer me, i need to get this working fast as possible and would really appreciate some help.
Monday, May 12, 2008 6:37 AM
All replies
-
User1187105292 posted
DotNetNuke (www.dotnetnuke.com) is a free,open spirce portal that does tricks with the url like that.
If you don't get a link to a short article...
Monday, May 12, 2008 6:38 AM -
User1187105292 posted
DotNetNuke (www.dotnetnuke.com) is a free,open source portal that does tricks with the url like that.
If you don't get a link to a short article...
Monday, May 12, 2008 6:40 AM -
User-1472285584 posted
I thought this wasn't possible with IIS 6, only IIS 7... but a quick search gave me this article as a workaround:
http://msmvps.com/blogs/omar/archive/2007/04/29/serve-extensionless-url-from-asp-net-without-using-isapi-module-or-iis-6-wildcard-mapping.aspx
Monday, May 12, 2008 9:31 AM -
User-711996264 posted
Yea i found that article and the idea works, but when i use this line Request.Url.Query.ToString() it gives me the actual 404.aspx url instead of the requested url. In the immediate window it shows the actual request but when i use it like this string reqUrl = Request.Url.Query.ToString() regUrl always holds the 404.aspx page. I cant figure out why its doing this. If i could get the actual request url i can make this work.
Monday, May 12, 2008 9:12 PM -
User-711996264 posted
Any idea why it does this?
Tuesday, May 13, 2008 10:58 AM -
User-1472285584 posted
Hmmm, what about the Request.UrlReferrer ? Maybe that one holds the original request?
Thursday, May 15, 2008 4:00 AM -
Thursday, May 15, 2008 8:32 AM
-
User-711996264 posted
I have it working on the local server using this.
protected void Application_BeginRequest(object sender, EventArgs e)
{
// HTTP 404 redirection for extensionless URL or some missing file
string currentPath;
string customPath;
currentPath = Request.Path.ToLower();
if (System.IO.Path.GetExtension(currentPath) == "")
{
// the request is within the /CONTENT/ directory, so re-write the URL to appear to be a filename, rather than a URL with a query string.
customPath = String.Format("~/Profiles.aspx?uName={0}", System.IO.Path.GetFileNameWithoutExtension(Request.Path));
Context.RewritePath(customPath);
}
}When i run this on the remote server at disountasp on a 208 server with asp.net 3.5 i get page not found. Any idea what the difference would be?
Sunday, May 18, 2008 9:29 PM -
User1505216132 posted
Hello
I am facing the same problem, have u got any good result on this?.
Monday, December 21, 2009 7:19 AM