MonoX 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.

URL - Rewritting - Changing profiles links.  (Mono Support )

Viewed 40116 time(s), 9 post(s) 10/10/2011 5:13:16 PMby shawndg
shawndg

shawndg

10/10/2011 5:13:16 PM
Hello Guys,

I know its been a while since I posted but I been trying to figure out how to get this url rewritting to work on our site in such a way that our profile links work just like facebooks..

example, I want mysite.com/bob to point to bob profile...

Ok.. here the major issue / concern..
How do I do this without our pages conflicting with theirs..

I have url rewritting default + my new stuff..
<!---basic navigation TheScene-->
<rewrite url="^(.*)/scenenews(.*)" to="$1/News.aspx" rewrite="$1/News.aspx" /> name="NewsPage/" />
<rewrite url="^(.*)/concerts(.*)" to="$1/concerts.aspx" rewrite="$1/concerts.aspx" /> name="ConcertsPage/" />
<rewrite url="^(.*)/contact(.*)" to="$1/Contact.aspx" rewrite="$1/Contact.aspx" /> name="ContactPage/" />
<rewrite url="^(.*)/onlinestore(.*)" to="$1/OnlineStore.aspx" rewrite="$1/OnlineStore.aspx" /> name="OnlineStorePage/" />
<rewrite url="^(.*)/Artists(.*)" to="$1/Artists.aspx" rewrite="$1/Artists.aspx" /> name="ArtistPage/" />
<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/" />

My concert is conflicting..

Is there a list of combinations of all the url rewrites that may cause me a issue I can go threw or create of problem urls where I can make sure the user does not use one of those names during registration... example cant call them selfs scenenews or concerts..
This content has not been rated yet. 
1871 Reputation 252 Total posts
khorvat

khorvat

10/11/2011 9:27:09 AM
Hi,

yes there is an RewrittenPaths.tt T4Template that is used to strongly type the URL rewriting rules. So you can use it like this:

In MonoX case
MonoSoftware.MonoX.RewrittenPaths.BlogPost.UrlPattern
or
MonoSoftware.MonoX.RewrittenPaths.BlogPost.Url

For your own rules I have attached the T4Template so you can generate your own strongly type URL rewriting rules, so you will use it like this
MonoSoftware.MonoX.RewrittenPaths.ConcertsPage.UrlPattern
or
MonoSoftware.MonoX.RewrittenPaths.ConcertsPage.Url


Regards 
This content has not been rated yet. 
15993 Reputation 2214 Total posts
denis

denis

10/11/2011 10:35:19 AM
Hi Shawn,
If I understand everything correctly, having URLs of the form "mysite.com/bob" reuiqres you to be very careful with all other URLs - it is much easier to have at least one, arbitrarily long/short URL segment that will be used to distinguish this type of URLs from other URLs (for example mysite.com/home/bob/ or whatever). For example, a pattern url="mysite.com/(.*)/$ would match your URL, but you would be very careful with all other "root" URLs, write more advanced patterns for profile URLs that has query parameters, etc.
This content has not been rated yet. 
7207 Reputation 956 Total posts
shawndg

shawndg

10/11/2011 12:59:47 PM
ya, I even considered the possibility of moving all my files into its own root folder but I don't think monox or even .net supports that.. I though if I moved all my files into a pages dir. that wound possible solve the conflicts and just expose the default.asp on the root. But I tried doing this but quickly ran into problems that I think where more then I wanted. I then thought.. OK url rewrittimy seems to be overriding dirs any ways so there is no need to move the files. Now IM just kinda stuck at the conflicting issue with Monox url rewrites conflicting with profile names. Im wondering is I could rewrite the build in monox url rewrites or if I even have too. it looks like a lot of them are for things I dint use.. like blogs, languages, groups. I don't think its a good idea to just remove them and IM not sure if changing them is possible without a ton of work. regarding your subfolder idea, my client is hell bent on facebook/urls.. so I need to figure something out.
This content has not been rated yet. 
1871 Reputation 252 Total posts
denis

denis

10/11/2011 4:52:48 PM
I am not sure that I follow you on the "conflicting" part of your post. You can take out all the rules you don't need. You can also position your rules before MonoX rules (the general principle is to have more specific - focused rules at the top of the list). Additionally, you can control the processing chain by putting the processing="stop" directive in any of your rules if you need the processing to be discountinued after a rule fires.
That being said, you can go with FB-style URLs, but need to be very careful with all other rules. So, instead of the default

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

You would go with something like this, and place it ON THE TOP of the list

<rewrite url="^/(.*)/$" to="/MonoX/Pages/SocialNetworking/UserProfile.aspx?UserName=$1" name="Profile" urlPattern="/{UserNameUrlEncoded}/" />

This content has not been rated yet. 
7207 Reputation 956 Total posts
pajo

pajo

10/12/2011 12:03:30 PM
I think Denis made a mistake rule should go on the bottom of the list otherwise it will pickup for example concerts and transfer request to user profile page instead of concerts page.

Anyway I agree with Denis having one more segment leads to a much simpler and easier to maintain solution. For facebook like links you must take care when adding new rule to keep correct rule order and also when adding new page that could possibly conflict with user profile to include it in reserved word list and missing anything can lead to a errors that are easy to miss.
This content has not been rated yet. 
629 Reputation 83 Total posts
denis

denis

10/12/2011 12:56:13 PM
As always, Pajo is correct. I forgot that you have many root level URLs. The most universal one should go to the bottom.
This content has not been rated yet. 
7207 Reputation 956 Total posts
shawndg

shawndg

10/13/2011 4:05:31 PM
Ok,  I think I am on to something here..

so far I figured out that all the web parts / built into Monox read urls from the web config when you load them..

So you cant remove any of them, but this is good news because that means.. you can customize them all..

Ok.. so now I have created the following url rewrites..
all appear to be working but.. now I want to make the default monox pages work the same way..
I am not sure on what patterns to provide though..

Below is what I have..

<!--- 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="^(.*)/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="^(.*)/(.*)/post/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostId=$4&$7" name="BlogPost" defaultPage="/Blog.aspx" urlPattern="/{PageName}/post/{Blog.Slug}/{IdentityId}/{Slug}/" />
    <rewrite url="^(.*)/(.*)/posts/(.*)/Page/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPageNo=$4&$6" name="BlogPostsPaged" defaultPage="/Blog.aspx" urlPattern="/{PageName}/posts/{Slug}/Page/{PageNo}/" />
    <rewrite url="^(.*)/(.*)/posts/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&$5" name="BlogPosts" defaultPage="/Blog.aspx" urlPattern="/{PageName}/posts/{Slug}/" />
    <rewrite url="^(.*)/(.*)/search/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&SearchAction=$4&SearchValue=$5&$7" name="BlogSearch" defaultPage="/Blog.aspx" urlPattern="/{PageName}/search/{Slug}/{SearchAction}/{SearchValue}/" />
    <rewrite url="^(.*)/(.*)/blog-tag/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&SearchAction=tag&SearchValue=$4&$6" name="BlogTag" defaultPage="/Blog.aspx" urlPattern="/{PageName}/blog-tag/{Slug}/{Tag}/" />
    <rewrite url="^(.*)/(.*)/settings/(.*)/(\?(.+))?$" to="$1/$2.aspx?ShowBlogSettings=true&BlogSlug=$3&$5" name="BlogSettings" defaultPage="/Blog.aspx" urlPattern="/{PageName}/settings/{Slug}/" />
    <rewrite url="^(.*)/(.*)/comments/(.*)/(\?(.+))?$" to="$1/$2.aspx?ShowBlogCommentsAdmin=true&BlogSlug=$3&$5" name="BlogCommentsAdmin" defaultPage="/Blog.aspx" urlPattern="/{PageName}/comments/{Slug}/" />
    <rewrite url="^(.*)/(.*)/edit/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostId=$4&BlogEditMode=true&$7" name="BlogPostEdit" defaultPage="/Blog.aspx" urlPattern="/{PageName}/edit/{Blog.Slug}/{IdentityId}/{Slug}/" />
    <rewrite url="^(.*)/(.*)/insert/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogInsertMode=true&$5" name="BlogPostInsert" defaultPage="/Blog.aspx" urlPattern="/{PageName}/insert/{Slug}/" />
    <!-- shows all blog posts regardless of the blog they were posted to -->
    <rewrite url="^(.*)/(.*)/posts/(\?(.+))?$" to="$1/$2.aspx$3" name="AllBlogPosts" defaultPage="/Blog.aspx" urlPattern="/{PageName}/posts/{Slug}/" />
    <rewrite url="^(.*)/(.*)/posts/(.*)/wlwmanifest.xml(\?(.+))?$" to="$1/wlwmanifest.xml" name="WlwManifest" urlPattern="/wlwmanifest.xml" /><set property="SocialNetworkingFolder" value="/MonoX/Pages/SocialNetworking/" />
 
    <!-- file view -->
    <rewrite url="^(.*)/fileview/(.*)/(.*)/(\?(.+))?$" to="$1${SocialNetworkingFolder}FileView.aspx?FileId=$2&ReturnPageId=$3&$5" name="FileView" urlPattern="/fileview/{FileId}/{ReturnPageId}/" />
    <rewrite url="^(.*)/fileviewsa/(.*)/(.*)/(\?(.+))?$" to="$1${SocialNetworkingFolder}FileViewStandalone.aspx?FileId=$2&ReturnPageId=$3&$5" name="FileViewStandalone" urlPattern="/fileviewsa/{FileId}/{ReturnPageId}/" />
    <rewrite url="^(.*)/(.*)/filelist-tag/(.*)/(\?(.+))?$" to="$1/$2.aspx?fTag=$3&$5" name="FileListTagFilter" urlPattern="/{PageName}/filelist-tag/{Slug}/" />
  
    <!-- site search -->
    <rewrite url="^(.*)/search/(.*)/(\?(.+))?$" to="$1/MonoX/Pages/MonoX/SearchResults.aspx?srchq=$2&$4" name="SiteSearch" urlPattern="/search/{Query}/" />
     
    <!-- dynamic group rules, can be used regardeless of the actual name of the page that holds group parts -->
    <rewrite url="^(.*)/(.*)/GroupView/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?GroupId=$3&$6" name="GroupView" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/GroupView/{ShortId}/{Slug}/" />
    <rewrite url="^(.*)/(.*)/GroupEdit/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?GroupId=$3&EditMode=true&$6" name="GroupEdit" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/GroupEdit/{ShortId}/{Slug}/" />
    <rewrite url="^(.*)/(.*)/GroupList/(\?(.+))?$" to="$1/$2.aspx$3" name="GroupList" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/GroupList/" />
    <rewrite url="^(.*)/(.*)/GroupInsert/(\?(.+))?$" to="$1/$2.aspx?InsertMode=true&$4" name="GroupInsert" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/GroupInsert/" />
    <rewrite url="^(.*)/(.*)/GroupSearch/(.*)/(\?(.+))?$" to="$1/$2.aspx?SearchValue=$3&$5" name="GroupSearch" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/GroupSearch/{SearchValue}/" />
    <rewrite url="^(.*)/(.*)/GroupSearch/(\?(.+))?$" to="$1/$2.aspx?ShowAllGroups=true&$4" name="GroupSearchShowAll" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/GroupSearch/" />
    <rewrite url="^(.*)/(.*)/GroupCategory/(.*)/(\?(.+))?$" to="$1/$2.aspx?Category=$3&$5" name="GroupCategory" defaultPage="/MonoX/Pages/SocialNetworking/Groups.aspx" urlPattern="/{PageName}/GroupCategory/{CategorySlug}/" />
     
    <!-- social networking general -->
    <rewrite url="^(.*)/RequestConfirmation/(.*)/(.*)/(\?(.+))?$" to="$1/MonoX/Pages/MonoX/Confirmation.aspx?RequestType=$2&RequestId=$3&$5" name="RequestConfirmation" urlPattern="/RequestConfirmation/{RequestType}/{RequestId}/" />
     
    <!-- Photo Gallery -->
    <rewrite url="^(.*)/(.*)/activeview/(.*)/albumview/(.*)/(\?(.+))?$" to="$1/$2.aspx?AlbumId=$4&activeview=$3&$6" name="PhotoList" defaultPage="/MonoX/Pages/SocialNetworking/PhotoGallery.aspx" urlPattern="/{PageName}/{ActiveControlAction}/{ActiveControlValue}/{AlbumView}/{AlbumId}/" />
    <rewrite url="^(.*)/(.*)/activeview/(.*)/photoview/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?FileId=$4&AlbumId=$5&activeview=$3&$7" name="PhotoView" defaultPage="/MonoX/Pages/SocialNetworking/PhotoGallery.aspx" urlPattern="/{PageName}/{ActiveControlAction}/{ActiveControlValue}/{PhotoView}/{PhotoId}/{AlbumId}/" />
     
    <!-- discussion board -->
    <rewrite url="^(.*)/(.*)/dboard/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?boardId=$3&$6" name="Discussion" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/{PageName}/dboard/{BoardId}/{Slug}/" />
    <rewrite url="^(.*)/(.*)/dtopic/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?topicId=$3&$6" name="DiscussionTopic" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/{PageName}/dtopic/{TopicId}/{Slug}/" />
    <rewrite url="^(.*)/(.*)/dfilter/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?tftype=$3&$6" name="DiscussionTopicFilter" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/{PageName}/dfilter/{FilterType}/{Slug}/" />
    <rewrite url="^(.*)/(.*)/dfilter-tag/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?tftype=$3&dbtTag=$4&$6" name="DiscussionTopicTagFilter" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/{PageName}/dfilter-tag/{FilterType}/{Slug}/" />
    <rewrite url="^(.*)/(.*)/dmessage/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?dmsgId=$3&dmsgMode=$4&$6" name="DiscussionEditMessage" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/{PageName}/dmessage/{MessageId}/{Mode}/" />
   
    <!-- dynamic content page -->
    <rewrite url="^(.*)/ContentPage/(.*)/(\?(.+))?$" to="$1/MonoX/Pages/Content.aspx?hdci=$2&$4" name="ContentPage" urlPattern="/ContentPage/{ContentId}/" />
 
    <!-- my custom profile TheScene -->
    <set property="MusicProfile" value="/CustomProfiles/MusicProfile/" />
    <rewrite url="^(.*)/(.*)/(\?(.+))?$" to="$1${MusicProfile}/Music.aspx?UserName=$2" name="Profile" urlPattern="/{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>

Here is a example of one I want to rewrite..

<rewrite url="Pages/post/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&amp;BlogPostId=$4&amp;$7" name="BlogPost" defaultPage="/Blog.aspx" urlPattern="/{PageName}/post/{Blog.Slug}/{IdentityId}/{Slug}/" />

But something tells me I am doing that wrong.. any help guess would be appreciated as always =)

This content has not been rated yet. 
1871 Reputation 252 Total posts
khorvat

khorvat

10/14/2011 1:31:27 PM
Hi,

here is the sample of one of the rules:
<rewrite url="^(.*)/some-prefix/scenenews/(\?(.+))?$" to="$1/PathToYourPage/YourPageName.aspx?$3" name="SceneNews" urlPattern="/some-prefix/scenenews/" />

Your rule
<rewrite url="Pages/post/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostId=$4&$7" name="BlogPost" defaultPage="/Blog.aspx" urlPattern="/{PageName}/post/{Blog.Slug}/{IdentityId}/{Slug}/" />

Fixed rule
<rewrite url="^(.*)/(.*)/Pages/post/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostId=$4&$7" name="MyBlogPost" defaultPage="/Blog.aspx" urlPattern="/{PageName}/Pages/post/{Blog.Slug}/{IdentityId}/{Slug}/" />

Does this helps you ?

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts