Mono Support How to Rewrite the URL of "Back To All Discussion Boards" link? 

Viewed 25209 time(s), 7 post(s), 11/7/2013 1:20:29 AM - by bkkmono
11/7/2013 1:21:30 AM
434 Reputation 51 Total posts

Hello,

I read the previous posts about rewriting URLs of a discussion board in MonoX to create SEO-Friendly URLs, then I wrote my own rewrite tags in web.config, everything works fine. For instance, 


<
rewrite url="^(.*)/mynewboard/(.*)/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/MonoX/Pages/SocialNetworking/Discussion.aspx?boardId=$2&$4=$5&$7" name="DiscussionPaged" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/mynewboard/{BoardId}/{Slug}/" />
 <rewrite url="^(.*)/mynewboard/(.*)/(.*)/(\?(.+))?$" to="$1/MonoX/Pages/SocialNetworking/Discussion.aspx?boardId=$2&$5" name="Discussion" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/mynewboard/{BoardId}/{Slug}/" />

However, I have a problem when I am on a discussion board page. The "Back to All Discussion Boards" link is still linked to page: "http://www.mydomain.com/MonoX/Pages/SocialNetworking/Discussion.aspx?=", not be the rewritten url.

I tried to write my own rewrite tag for Discussion.aspx like this: 
<rewrite url="^(.*)/mydiscussion$" to="$1/MonoX/Pages/SocialNetworking/Discussion.aspx" name="MyDiscussion" defaultPage="/MonoX/Pages/SocialNetworking/Discussion.aspx" urlPattern="/mydiscussion" />
When I browse to "http://www.mydomain.com/mydiscussion", it works fine by displaying the Discussion.aspx but the "Back to All Discussion Boards" link is still linked to "http://www.mydomain.com/MonoX/Pages/SocialNetworking/Discussion.aspx?=".

How to Rewrite the URL of "Back To All Discussion Boards" link?

1
11/7/2013 11:55:18 AM
2218 Reputation 300 Total posts

Hello,

The Back to all discussion boards link takes into account current request to generate a link back. You could create a custom control and OnPreRender set a different link.

Regards,
Mario

2
11/7/2013 2:41:36 PM
434 Reputation 51 Total posts

How could I do that? Please suggest me more.

However, I just solved this on my own. I changed the link of the Back to All Discussion Boards by adding client script in Discussion.aspx like the following Javascript code:

<script type="text/javascript">
       document.getElementById("client_id").href="/my_new_discussion_rewrite_page";
</script>



3
11/7/2013 2:58:45 PM
2218 Reputation 300 Total posts

Hello,

That is one way to resolve your problem. The solution I proposed would require you to create a new discussion topic web part(s) which inherit MonoX's discussion topic web part(s). In your inherited discussion topic web part(s) you could set the lnkBack NavigateUrl property. Finally just change the Register declarations to point towards your custom web part(s).

Regards,
Mario

4
11/7/2013 4:46:44 PM
434 Reputation 51 Total posts

Would it require to have the full MonoX source code to create a web part?
I can't compile to create a new web part from the free version of MonoX.

5
11/7/2013 4:39:48 PM
2218 Reputation 300 Total posts

No. You'd just need to create a custom discussion page and inherit MonoX's discussion page as well and change relevant Register declarations. The following applies if you followed this tutorial on how to create a custom MonoX based project: http://www.mono-software.com/blog/post/Mono/95/Building-a-custom-ASP-NET-project-based-on-MonoX/

Regards,
Mario

6
11/7/2013 5:41:33 PM
434 Reputation 51 Total posts

Thank you. I will learn and try to create my own web part as your suggestion.

7
This is a demo site for MonoX. Please visit Mono Software for more info.