tags:

views:

70

answers:

4

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 .xml 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?

+1  A: 

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

Maggie
do you know which part I should look for?
EquinoX
You can get the code here: http://dasblog.codeplex.com/ I'm not sure where to look as I've not looked at the source in a long time, but I would start with the macros.cs in the web.core and the templates in the theme folders.
Maggie
A: 

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.

Hrishi
okay say I have the title hyperlinked to blog.aspx?title=blog%20title1then how would I write the code to show the specific blog entry only?
EquinoX
A: 

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.

Jan Jongboom
I don't even have the my-article-title.aspx yet.. but I have a home page which has all the blog post inside a div tag... now what I want is that when a user clicks on the post title on the home page it will redirect to http://localhost/my-article-title.aspx
EquinoX
A: 

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

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:

rtpHarry