开发者

simple blog engine for website

I know that there's a lot of free open source blog engine out there such as BlogEngine.NET. However that's an overkill for my purpose... I so far has created my own simple one by storing posts in a .xm开发者_JAVA百科l file and so every time the main page loads it reads from all those xml files and displays it as posts.

Now my problem is when a user clicks on a post title I want it to show on a new page(.aspx), so if the title is X then I want a new page called X.aspx when the user clicks on the title on the homepage. I hope this makes sense.

My question is how do I create such thing?


I'd suggest you look at the code for dasBlog as it has very similar behavior to this.


One approach would be to pass a parameter in the link.

For example : blog.aspx?title=blog%20title1

In blog.aspx, accept parameter "title" and show the specific blog entry only.


You will need a rewrite-engine like UrlRewriter.net, that translates your url's from

http://localhost/my-article-title.aspx

to

http://localhost/posting.aspx?title=my-article-title

In your Page_Init of the posting.aspx page, load the title parameter, and look for the posting in your XML file with that title (f.e. using XPATH or LINQ2XML). Then display the needed information from the XML file.


You can use a third party library called urlrewriter.net its available:

  • http://urlrewriter.net/

You will need access to IIS (VPS or Dedicated hosting) if you want to implement extensionless urls (ie with the .aspx on the end).

I have written an article which explains how to set this up in a very clean way:

  • http://runtingsproper.blogspot.com/2009/11/advanced-url-rewriting-for-rest-of-us.html


This is an old post, but I figured I'd share for future readers... check out "Nickel". It's a super easy to use C#.NET blog engine. It uses URL routing to produce short, clean URLs based on the page title.

http://nickel.codeplex.com/

This produces URLs like:

http://www.mysite.com/a-web-page-title
http://www.mysite.com/an-authors-name
http://www.mysite.com/a-tag

Where the "subdirectory" leads you to the appropriate article or articles.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜