Last post Apr 06, 2005 09:15 AM by dannyboy78
Apr 04, 2005 12:02 AM|joefredriks21|LINK
Has anyone been able to successfully rewrite urls in the portal? I've looked through the rewrite.net sample code on the 15seconds.com web site, but havent been able to make it work.
Apr 06, 2005 09:15 AM|dannyboy78|LINK
I am just finishing a site that is based on the portal starter kit but seems to have morphed a bit, but anyway I have managed to implement url rewriting into the project.
I started off reading this article on msdn written by Scott Mitchell
http://http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/urlrewriting.asp. This then set me off, I created the httpmodule to handle the rewriting in the begin request event and I added a new column to the xml config file and schema
called friendly url, so now each tab has a friendly page name e.g. home.aspx. In the httpmodule I just grab an instance of the config and the page name from the url and iterate through running a regex match on page name and the friendly url column in the config
file if theres a match I take its tabID and build up the url, as follows.
For Each row As portalConfig.TabRow In config.Tab
pattern = String.Concat("^", row.friendlyUrl, "$")
re = New Regex(pattern, RegexOptions.IgnoreCase)
If re.IsMatch(page) Then
url = String.Concat(Global.getApplicationPath(app.Request), "/default.aspx")
app.Context.RewritePath(url, String.Empty, Global.buildQueryString(pageVars))
pageVars is a hastable that I initially populate with any querystring variables, which I then build into a querysting and then rewite the path to the url and the querystring.
I found Scotts article one of the best as it covered a lot of areas that were missed when I was looking for information on this myself things like handling post backs and actionless form.
Hope this helps.