Open-source my personal website

Source: Internet
Author: User

After learning C # basics both last week and last weekend, I finally got a different approach this week (ah! Nima is still facing the computer, not the sister T_T ). Since I saw Boyou share the frontend framework Bootstrap in the garden last time, I have always wanted to use it for a small site. I finally tried it this weekend (I have read all the demos on the Bootstrap official website before, but it is not hard for the kids shoes I haven't studied, it has achieved the simple style I want (in fact, it cannot be complicated for me to do so ). All right, let's stop talking about the nonsense. We just need to build a picture. Interested in children's shoes can also directly look at the real body: Portal http://heku.hk-001.jd43.com/(their own domain name has not been bound up)

1. Image and truth

This is the home page (I don't know how to do this on the home page, but I finally got it like this)

This is the blog page (the data comes from the blog site Rss)

This is a Weibo page (this is easy to understand, and a Sina Open Platform Component is put directly)

There are two more labs (I plan to keep some examples in the Lab) and I will not post them.

2. Brief Introduction to source code

As can be seen from careful friends, I am only presenting and not doing data storage here, so the source code is actually very simple and you can understand it without introducing it. However, I 'd like to try it out quickly. I am not very familiar with mvc. If there are any optimizations, please give me some advice.

First, the website structure is as follows (in addition to those provided by MVC, the extra parts have been marked ):

ErrorFilterFile, which can be handled when an exception is defined by the user. Here, the logic for sending emails to me when an exception is added.

AppHelperFile, I generally like to use a file named AppHelper to read and write the configuration file. In this way, if the node name is changed in the configuration, the project only needs to be changed in this class, you do not need to modify other references.

MailHelperFile, which is a simple encapsulation of Microsoft's WebMail class. Remember to configure the mailbox information here before you run it. why not put it on the Web. config. Because of the password, it is too expensive to upload it to a cheap host...

XMLHelperFile, parse the blog site Rss, And the BlogModel under the Models folder is an entity class I wrote against the blog site Rss.

3. Several minor issues

1. A problem encountered during the implementation process is that the menu is selected (when the "Homepage" menu is selected, the "blog" menu on the blog page is selected ).

The menu is placed in a partition view (_ Navbar. cshtml). You can select different menus on different pages and determine the Action name when each menu is generated:

@ Helper CheckRoute (string action) {bool result = string. equals (action, Request. requestContext. routeData. values ["action"]. toString (), StringComparison. ordinalIgnoreCase); if (result) {<text> class = "active" </text >}< div class = "navbar-inverse navbar-fixed-top"> <div class = "navbar-inner"> <div class = "container"> <a class = "brand" href = "@ Url. action ("Index", "Home ") "tabindex ="-1 "> HEKU </a> <ul class =" nav "> <li @ CheckRoute (" Index ")> <a href =" @ Url. action ("Index", "Home") "tabindex =" 1 "> homepage </a> </li> <li @ CheckRoute (" Blog ")> <a href = "@ Url. action ("Blog", "Home") "tabindex =" 2 "> Blog </a> </li> <li @ CheckRoute (" Weibo ")> <a href = "@ Url. action ("Weibo", "Home") "tabindex =" 3 "> Weibo </a> </li> <li @ CheckRoute (" Lab ")> <a href = "@ Url. action ("Lab", "Home ") "tabindex =" 3 "> lab </a> </li> @ * laboratory * @ <li @ CheckRoute (" About ")> <a href =" @ Url. action ("About", "Home ") "tabindex =" 5 "> about </a> </li> </ul> </div>

I wonder if there is any better way? What do you do in general?

2. During the custom log interceptor process, you also encountered a problem that was not resolved. Please advise!

The following is the code for this class (logic for sending emails when exceptions are added ):

Public sealed class ErrorFilter: HandleErrorAttribute {public override void OnException (ExceptionContext filterContext) {base. onException (filterContext ); // Exception information StringBuilder content = new StringBuilder ("================== Exception ========== ==== "); content. append ("

The problem is the part commented out in the figure. It was originally intended that the mail was sent asynchronously. No results. An error is returned! Please let me know why. (Error reproduction method: Configure MailHelper first, and then configure Web. configure the email recipient in Config, change the above Code to asynchronous, and then throw an exception in the Action .)

4. How can I get the source code to "make it difficult"

If you feel that the page is still working and want to modify it on this basis, then:

First, you need to change the three parts in Web. Config to your own. (You don't need to change the Rss namespace. Everyone should do the same.) after the modification, the blog page should be your blog.

<! -- Blog blog Rss --> <add key = "Rss" value = "http://feed.cnblogs.com/blog/u/93918/rss"/> <! -- Blog Rss namespace --> <add key = "XMLNS" value = "http://www.w3.org/2005/Atom"/> <! -- The email address that receives exception information when the system is abnormal --> <add key = "MailTo" value = ""/>

Then configure the MailHelper class:

Static MailHelper () {// =================================================== Please configure your own here. ================================= WebMail. smtpServer = ""; WebMail. smtpPort = 0; WebMail. userName = ""; WebMail. password = ""; WebMail. from = ""; WebMail. smtpusedefacrecredentials = true ;}

Go to Sina Weibo (or other microblogging) Open Platform look for microblogging show components (SINA's http://app.weibo.com/tool/weiboshow), generate a script code, and then replace Weibo. the code in cshtml is yours at this time. (By the way, this microblogs component may not be displayed during local debugging. I don't know why, but someone has encountered this on the Internet .)

There are still the home page and two pages. You can directly change Index. cshtml and About. cshtml.

5. Source Code

Download the source code (Please discover it yourself ~), If any child shoes have been improved (whether functional or effective) on this basis, please share them with me ~~~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.