Mono support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Mono Support Profile - URL - Rewritting problem. 

Viewed 8136 time(s), 12 post(s) 2/28/2012 2:13:11 PMby shawndg

shawndg 2/28/2012 2:13:11 PM

Hello Guys,

Ok I been having a little problem with my profile url rewrite..
At first I thought it was me but then I found this page..


Dont work:

So now I can tell that its a problem with the default url rewrite..
Now I am not very good at URL rewriting so I dont know how to fix this =/

I played with it.. and I have yet to figure it out..

Below is my url rewitting patterns..

<!--- navigation TheScene-->
      <set property="PagesFolder" value="/Pages/" />
      <rewrite url="^(.*)/Pages/scenenews(.*)" to="/Pages/News.aspx" rewrite="${PagesFolder}$1/News.aspx" /> name="NewsPage/" />
      <rewrite url="^(.*)/Pages/concerts(.*)" to="/Pages/concerts.aspx" rewrite="${PagesFolder}$1/concerts.aspx" /> name="ConcertsPage/" />
      <rewrite url="^(.*)/Pages/contact(.*)" to="/Pages/Contact.aspx" rewrite="${PagesFolder}$1/Contact.aspx" /> name="ContactPage/" />
      <rewrite url="^(.*)/Pages/onlinestore(.*)" to="/Pages/OnlineStore.aspx" rewrite="${PagesFolder}$1/OnlineStore.aspx" /> name="OnlineStorePage/" />
      <rewrite url="^(.*)/Pages/Artists(.*)" to="/Pages/Artists.aspx" rewrite="${PagesFolder}$1/Artists.aspx" /> name="ArtistPage/" />
      <rewrite url="^(.*)/Pages/Video(.*)" to="/Pages/Video.aspx" rewrite="${PagesFolder}$1/Video.aspx" /> name="VideoPage/" />
      <rewrite url="^(.*)/MusiciansClassifieds(.*)" to="$1/MusiciansClassifieds.aspx" rewrite="$1/MusiciansClassifieds.aspx" /> name="MusiciansClassifiedsPage/" />
      <!--advanced classified navigation TheScene-->
      <set property="ClassifiedsFolder" value="/Classifieds/" />
      <rewrite url="^(.*)/Classifieds(.*)/(.*)/(.*)" to="${ClassifiedsFolder}$3/$4.aspx" /> name="ClassifiedsAddPage/" />
      <!-- dynamic blog post rules, can be used regardless of the actual name of the page that holds blog parts -->
      <rewrite url="^(.*)/(.*)/Pages/post/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostId=$4&$7" name="BlogPost" defaultPage="/Blog.aspx" urlPattern="/{PageName}/Pages/post/{Blog.Slug}/{IdentityId}/{Slug}/" />
      <rewrite url="^(.*)/(.*)/Pages/posts/(.*)/Page/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPageNo=$4&$6" name="BlogPostsPaged" defaultPage="/Blog.aspx" urlPattern="/{PageName}/Pages/posts/{Slug}/Page/{PageNo}/" />
      <rewrite url="^(.*)/(.*)/Pages/posts/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&$5" name="BlogPosts" defaultPage="/Blog.aspx" urlPattern="/{PageName}/Pages/posts/{Slug}/" />
      <rewrite url="^(.*)/(.*)/Pages/search/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&SearchAction=$4&SearchValue=$5&$7" name="BlogSearch" defaultPage="/Blog.aspx" urlPattern="/{PageName}/Pages/search/{Slug}/{SearchAction}/{SearchValue}/" />
      <rewrite url="^(.*)/(.*)/Pages/blog-tag/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&SearchAction=tag&SearchValue=$4&$6" name="BlogTag" defaultPage="/Blog.aspx" urlPattern="/{PageName}/Pages/blog-tag/{Slug}/{Tag}/" /> 
      <rewrite url="^(.*)/(.*)/Pages/settings/(.*)/(\?(.+))?$" to="$1/$2.aspx?ShowBlogSettings=true&BlogSlug=$3&$5" name="BlogSettings" defaultPage="/Blog.aspx" urlPattern="/{PageName}/Pages/settings/{Slug}/" />
      <rewrite url="^(.*)/(.*)/Pages/comments/(.*)/(\?(.+))?$" to="$1/$2.aspx?ShowBlogCommentsAdmin=true&BlogSlug=$3&$5" name="BlogCommentsAdmin" defaultPage="/Blog.aspx" urlPattern="/{PageName}/Pages/comments/{Slug}/" />
      <rewrite url="^(.*)/(.*)/Pages/edit/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostId=$4&BlogEditMode=true&$7" name="BlogPostEdit" defaultPage="/Blog.aspx" urlPattern="/{PageName}/Pages/edit/{Blog.Slug}/{IdentityId}/{Slug}/" />
      <rewrite url="^(.*)/(.*)/Pages/insert/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogInsertMode=true&$5" name="BlogPostInsert" defaultPage="/Blog.aspx" urlPattern="/{PageName}/Pages/insert/{Slug}/" />
      <!-- shows all blog posts regardless of the blog they were posted to -->
      <rewrite url="^(.*)/(.*)/Pages/posts/(\?(.+))?$" to="$1/$2.aspx$3" name="AllBlogPosts" defaultPage="/Blog.aspx" urlPattern="/Pages/{PageName}/posts/{Slug}/" />
      <rewrite url="^(.*)/(.*)/Pages/posts/(.*)/wlwmanifest.xml(\?(.+))?$" to="$1/wlwmanifest.xml" name="WlwManifest" urlPattern="/wlwmanifest.xml" /><set property="SocialNetworkingFolder" value="/MonoX/Pages/SocialNetworking/" />
      <!-- file view -->
      <rewrite url="^(.*)/Pages/fileview/(.*)/(.*)/(\?(.+))?$" to="$1${SocialNetworkingFolder}FileView.aspx?FileId=$2&ReturnPageId=$3&$5" name="FileView" urlPattern="Pages/fileview/{FileId}/{ReturnPageId}/" />
      <rewrite url="^(.*)/Pages/fileviewsa/(.*)/(.*)/(\?(.+))?$" to="$1${SocialNetworkingFolder}FileViewStandalone.aspx?FileId=$2&ReturnPageId=$3&$5" name="FileViewStandalone" urlPattern="Pages/fileviewsa/{FileId}/{ReturnPageId}/" />
      <rewrite url="^(.*)/Pages/(.*)/filelist-tag/(.*)/(\?(.+))?$" to="$1/$2.aspx?fTag=$3&$5" name="FileListTagFilter" urlPattern="/{PageName/Pages/filelist-tag/{Slug}/" />
      <!-- site search -->
      <rewrite url="^(.*)/pages/search/(.*)/(\?(.+))?$" to="$1/MonoX/Pages/MonoX/SearchResults.aspx?srchq=$2&$4" name="SiteSearch" urlPattern="/Pages/search/{Query}/" />
      <!-- dynamic group rules, can be used regardeless of the actual name of the page that holds group parts -->
      <rewrite url="^(.*)/(.*)/Pages/GroupView/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?GroupId=$3&$6" name="GroupView" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/Pages/GroupView/{ShortId}/{Slug}/" />
      <rewrite url="^(.*)/(.*)/Pages/GroupEdit/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?GroupId=$3&EditMode=true&$6" name="GroupEdit" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/Pages/GroupEdit/{ShortId}/{Slug}/" />
      <rewrite url="^(.*)/(.*)/Pages/GroupList/(\?(.+))?$" to="$1/$2.aspx$3" name="GroupList" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/Pages/{PageName}/GroupList/" />
      <rewrite url="^(.*)/(.*)/Pages/GroupInsert/(\?(.+))?$" to="$1/$2.aspx?InsertMode=true&$4" name="GroupInsert" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/Pages/GroupInsert/" />
      <rewrite url="^(.*)/(.*)/Pages/GroupSearch/(.*)/(\?(.+))?$" to="$1/$2.aspx?SearchValue=$3&$5" name="GroupSearch" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/Pages/GroupSearch/{SearchValue}/" />
      <rewrite url="^(.*)/(.*)/Pages/GroupSearch/(\?(.+))?$" to="$1/$2.aspx?ShowAllGroups=true&$4" name="GroupSearchShowAll" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/Pages/GroupSearch/" />
      <rewrite url="^(.*)/(.*)/Pages/GroupCategory/(.*)/(\?(.+))?$" to="$1/$2.aspx?Category=$3&$5" name="GroupCategory" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/Pages/GroupCategory/{CategorySlug}/" />
      <!-- social networking general -->
      <rewrite url="^(.*)/(.*)/Pages/RequestConfirmation/(.*)/(.*)/(\?(.+))?$" to="$1/MonoX/Pages/MonoX/Confirmation.aspx?RequestType=$2&RequestId=$3&$5" name="RequestConfirmation" urlPattern="/Pages/RequestConfirmation/{RequestType}/{RequestId}/" />
      <!-- Photo Gallery -->
      <rewrite url="^(.*)/(.*)/Pages/activeview/(.*)/albumview/(.*)/(\?(.+))?$" to="$1/$2.aspx?AlbumId=$4&activeview=$3&$6" name="PhotoList" defaultPage="/MonoX/Pages/SocialNetworking/PhotoGallery.aspx" urlPattern="/{PageName}/Pages/{ActiveControlAction}/{ActiveControlValue}/{AlbumView}/{AlbumId}/" />
      <rewrite url="^(.*)/(.*)/Pages/activeview/(.*)/photoview/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?FileId=$4&AlbumId=$5&activeview=$3&$7" name="PhotoView" defaultPage="/MonoX/Pages/SocialNetworking/PhotoGallery.aspx" urlPattern="/{PageName}/Pages/{ActiveControlAction}/{ActiveControlValue}/{PhotoView}/{PhotoId}/{AlbumId}/" />
      <!-- discussion board -->
      <rewrite url="^(.*)/(.*)/Pages/dboard/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?boardId=$3&$6" name="Discussion" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/{PageName}/Pages/dboard/{BoardId}/{Slug}/" />
      <rewrite url="^(.*)/(.*)/Pages/dtopic/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?topicId=$3&$6" name="DiscussionTopic" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/{PageName}/Pages/dtopic/{TopicId}/{Slug}/" />
      <rewrite url="^(.*)/(.*)/Pages/dfilter/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?tftype=$3&$6" name="DiscussionTopicFilter" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/{PageName}/Pages/dfilter/{FilterType}/{Slug}/" />
      <rewrite url="^(.*)/(.*)/Pages/dfilter-tag/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?tftype=$3&dbtTag=$4&$6" name="DiscussionTopicTagFilter" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/{PageName}/Pages/dfilter-tag/{FilterType}/{Slug}/" />
      <rewrite url="^(.*)/(.*)/Pages/dmessage/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?dmsgId=$3&dmsgMode=$4&$6" name="DiscussionEditMessage" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/{PageName}/Pages/dmessage/{MessageId}/{Mode}/" />
     <!-- dynamic content page -->
      <rewrite url="^(.*)/Pages/ContentPage/(.*)/(\?(.+))?$" to="$1/MonoX/Pages/Content.aspx?hdci=$2&$4" name="ContentPage" urlPattern="/Pages/ContentPage/{ContentId}/" />
      <!-- mobile dynamic content page -->
      <rewrite url="^(.*)/Pages/Mobile/Content/(.*)/(\?(.+))?$" to="$1/MonoX/Mobile/Content.aspx?hdci=$2&$4" name="MobileContentPage" urlPattern="/Pages/Mobile/Content/{ContentId}/" />
      <!-- my custom profile TheScene -->
      <set property="MusicProfile" value="/CustomProfiles/MusicProfile/" />
      <rewrite url="^(.*)/(.*)/(\?(.+))?$" to="$1${MusicProfile}/Music.aspx?UserName=$2" name="Profile" urlPattern="/{UserNameUrlEncoded}" />
      <rewrite url="^(.*)/music/(.*)/(\?(.+))?$" to="$1${MusicProfile}/Music.aspx?UserName=$2&$4" name="Profile" urlPattern="/music/{UserNameUrlEncoded}/" />
      <!-- do not remove the last rule - supports for default page if all rules above have failed -->
      <if url="^(.*)/\?language=(.*)(\?(.+))?$" rewrite="$1/Default.aspx?language=$2&$4" /></UrlRewriter>

The ones I have been experimenting with..

<rewrite url="^(.*)/(.*)/(\?(.+))?$" to="$1${MusicProfile}/Music.aspx?UserName=$2" name="Profile" urlPattern="/{UserNameUrlEncoded}" />
<rewrite url="^(.*)/music/(.*)/(\?(.+))?$" to="$1${MusicProfile}/Music.aspx?UserName=$2&$4" name="Profile" urlPattern="/music/{UserNameUrlEncoded}/" />

I really want my profile pages to work like facebook
This is why I changed all the url rewrites above however I am still a little scared that default MonoX functionality may still need fixed in some way..
So right now I am willing to settle with

But not .. I feel the / will confuse people. I would like it to work with or without it..
This content has not been rated yet. 
1871 Reputation 252 Total posts

denis 3/1/2012 7:58:26 PM

I think that we already talked about it:
The approach without "music" part of the URL could work, but it is more complicated, as you have to make sure that no other URL rewriting rule interferes with it, as it would catch all URLs without a slash in the path.
This content has not been rated yet. 
7147 Reputation 932 Total posts

shawndg 3/2/2012 10:32:56 PM


Proven to be extremely complicated..

I did manage to remove the back / requirement though for the profile name..

<set property="MusicProfile" value="/CustomProfiles/MusicProfile/"/>
<rewrite url="^(.*)/music/(.*)/?$" to="${MusicProfile}/Music.aspx?UserName=$2" name="Profile" urlPattern="/{UserNameUrlEncoded}"/>

so now i have domain/music/theband working..

I am still getting a lot of grief though about not getting the domains to domain/username =/

I am thinking other options at this point like i considered if I could figure out a easy way to do it..
but dont know how at the moment or if its even more complicated then the url rewrites.
This content has not been rated yet. 
1871 Reputation 252 Total posts

khorvat 3/3/2012 2:50:45 PM


yes, this can be a bit complicated but it is doable, I see that you maybe want to i implement the for this type of rewriting you need to implement custom module as I can recall. If you want to use that approach let me know and I'll try to provide you with the code to do this kind of url rewriting.

This content has not been rated yet. 
15013 Reputation 2072 Total posts

shawndg 3/3/2012 4:26:50 PM

I would be interesting in it although I am not sure how complicated it is..

I am worried that it may require DNS changes that may be a bit complicated..

But if you got any ideas I would like to see those..

I am thinking that may be a work around to the core url rewritting issue above with trying to make all the url rewrites work inside the pages idea..

My original idea was to move all of Monox into and then have anything other then pages point to - that would load a MonoX profile..

My concern though is with how complicated it is to write all those url rewrite paths and how much room for error I am introducing =/
This content has not been rated yet. 
1871 Reputation 252 Total posts

denis 3/4/2012 4:31:32 PM

This approach would require full control over your DNS and IIS, and it has nothing to do with MonoX. It cannot work on shared hosts. You would need to set up a wildcard DNS record to catch all possible band names, and use a similar IIS binding (only one binding of a type "All unasigned" is allowed per IP). As you can imagine, this is not the simplest scenario to work with.
You alternative approach could work, but as you've said it would require moving everything else one level down in the URL rewriting scheme. I guess this could be done, but it requires a lot of work.
This content has not been rated yet. 
7147 Reputation 932 Total posts

shawndg 3/4/2012 5:13:10 PM

Hi Guys,

Well good news is I do have complete control over the DNS.

I have a virtual dedicated server..

So If its not to complicated then I am game for trying it.

My guess is it will be less complicated then trying to rewrite all the paths to sub paths..
This content has not been rated yet. 
1871 Reputation 252 Total posts

denis 3/5/2012 10:02:21 PM

You would need to set up a wildcard DNS entry and IIS binding first:
After that, you would need to setup something along these lines in your URL rewriting rules:

<if header="HTTP_HOST" match="^(.+)\.domain\.com$"
    <set property="subdomain" value="$1" /> 
    <rewrite url="^/(\?(.+))?$" url="/Music.aspx?UserName=${subdomain}&$2" /> 

This content has not been rated yet. 
7147 Reputation 932 Total posts

shawndg 3/6/2012 5:13:36 PM

I got two problems..

<if header="HTTP_HOST" match="^(.+)\.thepittsburghscene\.com$">
<set property="subdomain" value="$1" />
<rewrite url="^/(\?(.+))?$" url="/Music.aspx?UserName=${subdomain}&$2" />

I tried setting the above code.. but it says its not well formated in web config.

I also notice that once I browse to that sub domain.. then m dns is pointing correctly and MonoX is loading.
but. all the links are assuming the subdomain.. =/ aka .. bla.test/pages/news

Not sure how to solve this short of rewitting all the paths..
This content has not been rated yet. 
1871 Reputation 252 Total posts

denis 3/8/2012 5:07:37 PM

It appears that our code formatter changed my rule a bit, so please try to use this:

<if header="HTTP_HOST" match="^(.+)\.thepittsburghscene\.com$">
 <set property="subdomain" value="$1" />
 <rewrite url="^/(\?(.+))?$" to="/Music.aspx?UserName=${subdomain}&amp;$2" />
This content has not been rated yet. 
7147 Reputation 932 Total posts
1 2