Link Problem

Topics: ASP.NET 2.0, Business Logic Layer, Controls, Themes
Oct 19, 2008 at 2:21 PM
Hello everyone. here is my problem. I have published the starter kit website in apache using Mod_AspDotNet and everything works perfect except some of the links.

the following links do not work at all:

1. <a rel="nofollow" href="<%=Post.RelativeLink %>#comment"><%=Resources.labels.comments %> (<%=Post.ApprovedComments.Count %>)</a> |

(when i click on comment - postview.ascx - Line 25)

2. Response.Redirect(post.RelativeLink.ToString());

(when i save post- add_entry.aspx.cs Line 241)

Please let me know if you can fix these problems.and your offer too.

waiting for your reply,


Oct 19, 2008 at 8:12 PM
Edited Oct 19, 2008 at 8:14 PM
I have also tried to run BlogEngine in Apache / Mod_AspDotNet environment.In my opinion, BlogEngine URL Rewriting does not work with Apache ( or I do not know how to configure Apache URL Rewritting ).
Oct 19, 2008 at 8:51 PM
hi mvincic are you sure it is a url rewriting problem? I downloaded the source to check the post.cs which has the relative link method. and here is the code:

public string RelativeLink
                string slug = Utils.RemoveIllegalCharacters(Slug) + BlogSettings.Instance.FileExtension;
                if (BlogSettings.Instance.TimeStampPostLinks)
                    return Utils.RelativeWebRoot + "post/" + DateCreated.ToString("yyyy/MM/dd/", CultureInfo.InvariantCulture) + slug;
                return Utils.RelativeWebRoot + "post/" + slug;

private string _Slug;
        /// <summary>
        /// Gets or sets the Slug of the Post.
        /// A Slug is the relative URL used by the posts.
        /// </summary>
        public string Slug
                if (string.IsNullOrEmpty(_Slug))
                    return Utils.RemoveIllegalCharacters(Title);

                return _Slug;
            set { _Slug = value; }

what do you think?


Oct 19, 2008 at 9:13 PM
Edited Oct 19, 2008 at 9:38 PM
Hi Mike,

this is how I understand the problem and I might be wrong. 
Please take a look at UrlRewrite.cs that maps Http Request of easy to remember URL ( http://localhost/BlogEngine.Web/post/blog1.aspx in 
your example ) to real post ( e.g. b663b6a1-1c34-4c60-a891-c14772507b23.xml ).

Apache error.log has "File does not exist " : C:/PathToBlogEngine.Web/post and post directory does not exist

Oct 19, 2008 at 10:47 PM
Hello mvincic:

I enabled url writing on my apache by uncommenting the mod_rewrite like this:  LoadModule rewrite_module modules/
but still links are not working. I also looked at the urlrewrite.cs file from the source.
context.RewritePath(Utils.RelativeWebRoot + "post.aspx?id=" + post.Id.ToString() + GetQueryString(context), false); and got this , i really don't know what to do.

is there a way, i can change the code to work without relative link and using the page as it is without easy to remember url. I just want this links towork on apache.

thanks in advance,

Oct 19, 2008 at 11:40 PM
Edited Oct 19, 2008 at 11:41 PM
Hello Mike,

I would also like that this links work in Apache, but lost too much time and switched to Visual Studio integrated Web Server for some smaller customizations and testing on my home machine. You can take a try and define URL Rewriting rules in Apache's httpd.conf ( google : apache url rewriting rules for useful guides).

Oct 20, 2008 at 1:33 PM
Hello mvincic:

I read some url rewriting rules documents, but still no luck. Is there a way I can just make the link for comment working? Since relativelink is not working for me on apache, I want the comment link to work without it. Please let me know.
<a rel="nofollow" href="<%=Post.RelativeLink %>#comment"><%=Resources.labels.comments %> (<%=Post.ApprovedComments.Count %>)</a>

waiting for any help,

Oct 21, 2008 at 2:43 PM
Is there anyone who can help me solve this problem. Please it is urgent. I really have to fix this link problem.

thanks in advance.
Oct 22, 2008 at 2:35 AM
Sorry I can't be any help, I don't know anything about running an apache server or how BlogEngine would interact with apache.  Also, I'm not so sure there are many people using BlogEngine.NET on Apache.
Oct 22, 2008 at 11:35 AM
Edited Oct 22, 2008 at 11:37 AM
Hello Mike,

instead of configuring Apache side, you can take a try and replace Blogengine's UrlRewrite.cs with some other .NET  UrlRewriting module like ones from or .  

I can give you only suggestions, not a solution : with Windows Apache and ( retired but fine ) Mod_AspDotNet you are always on your own. It is a rare configuration, not tested by .NET apps and not supported by hosting companies.
Nov 12, 2008 at 7:28 PM
Edited Nov 12, 2008 at 7:29 PM
I'm not familiar with Apache, but I think what you need to do is change the ".RelativeLink" property to ".AbsoluteLink"

I encountered a problem with the URL writer when I was wanting to add a "Digg" button to postview.ascx:
Rather than manually write html to add a button, digg has a javascript to add that displays a smart button with how many diggs it currently has.
     <script src="" type="text/javascript"></script>

If I enter just this, it will submit the digg article as "" which is what you would be seeing if viewing my site.
So, I added some parameters to point it to the URL of the actual post in which the digg button refers to:
    <script type="text/javascript">
    digg_url ="<%=Post.AbsoluteLink %>";      
    digg_skin = 'compact';            this is not important, it changes the skin of the button
    digg_window = 'new';            this just makes it open in a new window

The instructions from digg are to use digg_url = 'WEBSITE_URL'; as the value, and replace 'WEBSITE_URL' with the URL you want to use,
but since the URL I want is a dynamic URL encoded with the easy-to-remember-name by post.cs, I can the "Post.RelativeLink" property.
Since its submitting the link to a different site, I just changed it to ".AbsoluteLink" and it works perfectly.

If your problem as you described "is there a way, i can change the code to work without relative link and using the page as it is without easy to remember url. I just want this links towork on apache."
is just between using relative and absolute links, then changing that property should work for you.
edit: spelling errors