Daniel Palme

Daniel Palme

.NET consultant from Germany.

Blog > ASP.NET MVC 4 - Blog engine based on Twitter Bootstrap

ASP.NET MVC 4 - Blog engine based on Twitter Bootstrap

It's time to update my blog engine which I published some time ago. The updated version is now based on ASP MVC 4 and uses Twitter Bootstrap 3 instead of a custom CSS file. In this post I will give a short overview over the things that were changed.

Features/Setup

The features of the blog engine are described in this post.
The setup of the blog engine is quite easy. The directory 'Setup' contains a readme explaining the necessary steps.

Changes

Twitter Bootstrap

Twitter Bootstrap 3 uses a mobile first approach, that means that you don't have to integrate bootstrap-responsive.css any more.
The default design now looks like this:

MVCBlog

Dependency Injection

SimpleInjector is now used instead of Unity as IoC container. Why? It is one of the fastest containers with a lot of useful features.

Commands/CommandHandler

I decided to use the command pattern for modifying data. This is especially useful for bigger applications, but since the overhead is not that big, I applied this approach from @dot_NET_Junkie.

Updates

20.02.2014: Migrated to MVC 5.

Source Code

The latest source code can be found on GitHub.


Subscribe to RSS Feed

Tags: .NET, ASP, C#, MVC
 

Related posts

 

New comment

:

:

:

:

 

Comments

#1
Mika

Mika

09/08/2013

is it possible to create new users? :)
 
#2
Daniel

Daniel

09/08/2013

@Mika:
These is no register functionality and no user administration. But you you could add new user to Web.config (<Authentication /> section) manually.
 
#3
rodrigo

rodrigo

10/17/2013

Cool, thanks :D
I student your code now haha :p
 
#4
Dor

Dor

11/19/2013

Hey, I would like to use your blog engine as a base for my website.
But I'm not managing to figure out how to login
 
#5
Daniel

Daniel

11/19/2013

@Dor:
The default username and password is "admin". You could/should change this in web.config. See https://github.com/danielpalme/MVCBlog/blob/master/Setup/Readme.html for help.
 
#6
Dor

Dor

11/19/2013

I appreciate your help, but when ever I change the SHA1 password I get an error
 
#7
Dor

Dor

11/19/2013

It doesn't matter, I managed to fix it. I would like to ask as well how it is possible to edit or insert pre-exisiting data on to the sql since otherwise the dates would be wrong.
 
#8
reaper

reaper

05/14/2014

when I trying to run this website Got this error.
{"HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete."}
MVC.Blog.Tags()
MVC.Blog.PopularBlogEntries()
 
#9
teksonit

teksonit

07/31/2014 | http://www.teksonit.com

Great Information admin thanks For Your Information and Any body wants

learn .NET through Online for Details Please go through the Link

<a href="http://www.teksonit.com/dot-net-online-training/">
Best .NET Online Training in INDIA | .NET Certification Online in USA, UK, CANADA </a>

This Will Helps you aalot.
 
#10
Mein Name

Mein Name

09/02/2014

Any ideas how to deal with this run-time error?

HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete.

Source Error:

Line 21: <div class="col-md-3">
Line 22: <h3>@Common.Tags</h3>
Line 23: @{Html.RenderAction(MVC.Blog.Tags());}
Line 24:
Line 25: <h3>@Common.PopularPosts</h3>


Source File: c:\...\MVCBlog.Website\Views\Shared\Sidebar.Layout.cshtml Line: 23
 
#11
Daniel

Daniel

09/03/2014

@Mein Name:
There seems to be an issue with async child actions:
http://stackoverflow.com/questions/13959251/async-and-await-in-mvc-4-controller
https://aspnetwebstack.codeplex.com/workitem/601

I can't reproduce this on my machine, but fixing the problem is easy.
Will apply the necessary changes soon.
 
#12
Alec

Alec

09/09/2014

Are you considering implementing comment moderation? That appears to be the only downfall of an otherwise great project.
 
#13
Daniel

Daniel

09/09/2014

@Alec:
I have no plans for any modifications at this time.
My spam protection works pretty well (hidden website field and time stamp) and stupid comments are very rare on my blog, I delete them right after receiving the corresponding email notification.
 
#14
Rob

Rob

09/17/2014

How do I change the Tags?
 
#15
Daniel

Daniel

09/18/2014

@Rob:
When you are editing a blog entry you can add and remove its tags.
If you want to change an existing tag name, then you have to do this at database level. There in no specific UI for that.
 
#16
David

David

09/29/2014

Hello,
Thank you very much for this project! Really great! I have one question. I am not familiar with Dependency Injection and I would want to remove SimpleInjector and no dependency injection at all. Any advise how can I remove the SimpleInjector and make the blog work without that? I know I have to remove the nuget and so on but what I have to change in the code so I will make it work without dependency injection?

Thank you very much!
 
#17
Nico

Nico

10/16/2014

Hello if using this blog must i provide any credits?
 
#18
Daniel

Daniel

10/16/2014

@Nico:
No credits required.
 
#19
Robert

Robert

10/30/2014

Can you upload on Git the version which can be built out of box? The current one doesn't have solution file and doesn't build for me. Preferably changing it to web application project.
 
#20
Daniel

Daniel

10/30/2014

@Robert:
The Github repository contains a solutions file. You should be able to build to solution. Be sure you have Nuget package restore enabled.
 
#21
dave

dave

11/01/2014 | http://www.davidyardy.com

Is there any code/mechanism to import existing blog content via a blogml.xml file?
 
#22
Andrey

Andrey

11/21/2014

Hello!

I see an RSS icon on the screenshot. Does your blog engine support rss feed generating?

Thanks.
 
#23
Daniel

Daniel

11/21/2014

@Andrey:
Yes, that's supported
 
#24
R&#233;nald VENANT-VALERY

Rénald VENANT-VALERY

12/29/2014

Hello, many thanks for this blog engine. That's exactly what I was looking for. Simple, performant, minimalist, and very efficient.
 
#25
facupola

facupola

01/10/2015

thanks for all Daniel! it's an excellent project and it's works great! Very usefull and complete!!!
Regards!
 
#26
Alan

Alan

01/12/2015

Great project!

I have one issue though that I havent been able to resolve. After i downloaded the project , I ran the T4MVC.tt generator. It has errors and then the solution wont compile.

Error 82 Compiling transformation: Invalid token 'this' in class, struct, or interface member declaration
Error 83 Compiling transformation: Method must have a return type
Error 84 Compiling transformation: Type expected
 
#27
Daniel

Daniel

01/12/2015

@Alan:
Very strange issue.
When I download the ZIP file, I get the same error.
When I check out the files directly from Github, it seems to work.
 
#28
Alan

Alan

01/13/2015

Hi Daniel,

Yeah, I downloaded the zip. Thanks for looking into it. I will try getting it directly from GitHub for the tt files then.

BTW, your code excellent. Very clean. Thanks for sharing it!
 
#29
Alan

Alan

01/13/2015

BTW, the problem was that somehow the ZIP package had all the carriage returns stripped out with only line feeds in.

The first 8 bytes of the good t4hooks had a CR/LF
EF BB BF 23 2B 0D 0A

The first 8 bytes of the zipped t4hooks had only an LF
EF BB BF 23 2B 0A 2F

That probably messed up the TT parsing.
 
#30
Smith Cole

Smith Cole

01/17/2015

Thanks for this nice information. It is very nice and clear way to setup. It is a great post. It is a kind interesting to do so because of the integrating blog engine into an existing site. Last time I am hosting a web site that using myasp.net. I learn many more idea here.
 
#31
Ashish Ranjan

Ashish Ranjan

01/29/2015

Hi Denial,
Awesome job man. Good work!!
I downloaded your stuffs for learning purpose. So many things in your code are new. Give me guideline how can i improve my skills.
Thank you from core of my heart.

Thanks
 
#32
Naveed Akhtar

Naveed Akhtar

03/02/2015 | http://www.lightnodes.com

Hi Daniel,

Thanks for the blog engine. I have been thinking to integrate a CMS into my website, silly me, figured out, you can't integrate one. They want you to integrate your website into the CMS.

Which i can't afford at the moment.

A quick question, I want to use Unity, as its easier with Identity 2. I was using SimpleInjector before setting up Identity. It was just very complicated to set it up with it.

So, do you see any problem if I use Unity with your MVC4 / bootstrap implementation?
 
#33
Daniel

Daniel

03/02/2015

@Naveed:
You can of course use Unity instead of SimpleInjector.
But I don't understand why Unity should work better as SimpleInjector. Can you explain?
 
#34
Naveed Akhtar

Naveed Akhtar

03/05/2015 | http://www.lightnodes.com

Hi Daniel,

I personally preferred SimpleInjector over any other, simply because it's fastest, as fast as having no IoC Container. But SimpleInjector is not very simple when you like to integrate Identity 2 for roles and membership. As Identity use poor man's Ioc throughout and mostly implemented using multiple constructor methods for Controllers etc.

There are few people who overcome this by adding more code, which was getting too complicated for me and the whole purpose of SimpleInjector was to keep things simple and speedy, isn't it! While Unity is comparatively slow, but is very flexible. I spend almost half a day trying to support simpleInjector and then gave up later it took me less than an hour to make my website up and running again with Unity. Call it my incompetence, but personally I like to have very neat and less code in my projects, less code means less maintenance.
 
#35
mehmet

mehmet

04/15/2015

i download your blog project but i dont find username and password
 
#36
Dew

Dew

05/10/2015

After extracted 'src' folder. I open it with VS 2013 also run. But occur some error on global.aspx and application can't work.
 
#37
miguel

miguel

05/19/2015

muy super este articulo. gracias por compartir experiencia
 
#38
wajid

wajid

01/17/2016

Hello sir how i get these files of blog.............Help me......
 
#39
shashi

shashi

03/16/2016 | https://www.shashinewblog.com

hello, i have not make any query or table in sql but all content of blog like create new blog or post comments all save and never gone after refresh, i have question that how can be possible or working on your blog? can you please give a brief on it?..thankss
 
#40
James

James

05/13/2016

I just wanted to say thank you for this. I'm studying MVC and this code is robust enough to teach me some things and yet simple enough that I can run with it.

I hooked it up to a SQL 2012 DB and it worked on the first try. I had absolutely no issues. Kind of shocked by that actually. Great work.
 
#41
Bill Hamm

Bill Hamm

10/02/2016

Hello Daniel,

Great work. I am having trouble understanding exactly how to add on to this project. I am getting errors when I add typical MVC models and views. Would you briefly explain the process on adding a Contact page?
 
#42
Daniel

Daniel

10/03/2016

@Bill:
There nothing special. You could add a ContactController, the corresponding models and views. Then you implement the required methods in the controller.
Then you should update the code generated by T4MVC.tt (right click then select "Run custom code").
 
#43
Javi

Javi

11/15/2016

Any fast way to migrate sdf DB to a mdf??

Great project thx a lot!