2013年8月29日 星期四

Window內開啟指定JDK環境懶人法

我是懶人.

我的開機環境是JDK5, 但是也有JDK6的專案要執行, 常常換來換去很麻煩.

 

1.首先建立一個bat, 取名 JDK6.bat, 換成自已的JDK路徑

@echo off
cd /D %1
Set JAVA_HOME=C:\JDK\jdk1.6.0_25
Set PATH=C:\JDK\jdk1.6.0_25\bin;%PATH%

 

2.建立一個reg檔, 替換自己JDK6.bat的路徑

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\cmd_jdk16]
@="Open JDK1.6 Command Prompt Here"

[HKEY_CLASSES_ROOT\Directory\shell\cmd_jdk16\command]
@="cmd.exe /k \"C:\\yourpath\\JDK6.bat \"%L\"\""

 

3.這樣就可以輕鬆切換JDK環境了

JDK6

2013年8月16日 星期五

RedHat el5 安裝Mysql5.5

參考自 http://stackoverflow.com/questions/9361720/update-mysql-version-from-5-1-to-5-5-in-centos-6-2

節錄內容

To list Old MySql

yum list installed | grep -i mysql

To remove Old MySql

yum remove mysql mysql-*

Remi Dependency on CentOS 6 and Red Hat (RHEL) 6

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

Install MySQL server

yum --enablerepo=remi,remi-test install mysql mysql-server

To list New MySql

yum list installed | grep -i mysql

start MySql server


/etc/init.d/mysqld start ## use restart after update

OR


service mysqld start ## use restart after update
chkconfig --levels 235 mysqld on

Last

mysql_upgrade

Now my MySql version is 5.5.32

Ref:


http://www.webtatic.com/packages/mysql55/
http://www.if-not-true-then-false.com/2010/install-mysql-on-fedora-centos-red-hat-rhel/
 
------------------------------
我下的指令
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rpm –Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
yum --enablerepo=remi,remi-test install mysql mysql-server
/etc/init.d/mysqld
這樣就裝好了, 裝好Mysql後記得去更新password
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h vdb password 'new-password'

或者
/usr/bin/mysql_secure_installation



因為要建立一個DB並從另一台主機連線.
#mysql -u root -p
建一個資料庫
CREATE DATABASE mydatabase DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

給外部連線權限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'連線主機IP ' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON ‘%`.* TO 'root'@'連線主機IP ' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON `%`.* TO `root`@`連線主機IP` IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON moodle.* TO 'root'@'連線主機IP' IDENTIFIED BY 'password' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON moodle.* TO 'root'@'連線主機IP' IDENTIFIED BY 'password' WITH GRANT OPTION;
(忘了是哪一個,所以全部貼上)

 done.完成












2013年8月15日 星期四

Juno 沒有Tomcat?

請到 Help -> Install New Software 選擇 http://download.eclipse.org/releases/juno/ , 展開 "Web, XML, and Java EE Development", 安裝 JST Server Adapters及 JST Server Adapters Extensions .

更新後重啟Eclipse 然後安裝Tomcat 跟以前的方式一樣.

2013年8月14日 星期三

hibernate connection 隔夜被斷線的問題

最近因為一個Hibernate + Spring + Quartz  的Web專案,  執行完Quartz Scheduler  的Job後,  隔天早上就出現

SQL Error: 17002, SQLState: null
IO 異常: Connection reset
java.sql.SQLException: 關閉的連線

然後就是一堆
SQL Error: 0, SQLState: null
Already closed.
重覆的錯誤

(hibernate connection close overnight的問題, 隔夜connection中斷問題,或是自動重新連線問題…)

Hibernate官網論壇說到

You should never use Hibernate's built-in connection pooling in production; it is non-scalable and non-fault-tolerant. Instead, use DBCP or C3P0 (or, even better, an application server datasource).

Automatic reconnect from Hibernate to MySQL 提出用C3P0

CrazyTechThoughts 在 Resolve Hibernate connection timeout issue with MySQL server 也提出用 c3p0.testConnectionOnCheckout=true 的方法

StackOverflow也有人問 Hibernate, C3P0, Mysql — Broken Pipe

 

好像只能換Connection pool 的技術了, 但我不想將DBCP改為C3P0, 因為還有大部份舊的hibernate mapping 還在運行, 換了之後不知道還要花多少時間測試.

最後我的解決方式:

在 spring 的設定檔內

<bean>

<property name="validationQuery" value="SELECT 1 FROM DUAL" />
<property name="testOnBorrow" value="true" />

</bean>

因為我用的是OracleDB, 所以用 Select 1 From Dual, 其它資料庫請自行修改.

快一週了,好像還可以, 沒聽到有問題.

ORA-17059: Fail to convert to internal representation

could not read column value from result set 無法轉換為內部方式

這個錯誤原因是:資料庫裡的字段類型與Java裡映射該字段屬性的類型不能對應轉換,例如資料庫裡欄位類型為Varchar2,而Java定義的類型為Long;或者資料裡為Number,而Java定義的對應屬性類型為String。

處理*.hbm.xml大部份都能解決問題.

2013年8月10日 星期六

Organizing an ASP.NET MVC Application using Areas

The MVC pattern separates the model (data) logic of an application from its presentation logic and business logic. In ASP.NET MVC, this logical separation is also implemented physically in the project structure, where controllers and views are kept in folders that use naming conventions to define relationships. This structure supports the needs of most Web applications.
However, some applications can have a large number of controllers, and each controller can be associated with several views. For these types of applications, the default ASP.NET MVC project structure can become unwieldy(不便的).
To accommodate large projects, ASP.NET MVC lets you partition Web applications into smaller units that are referred to as areas. Areas provide a way to separate a large MVC Web application into smaller functional groupings. An area is effectively an MVC structure inside an application. An application could contain several MVC structures (areas).
For example, a single large e-commerce application might be divided into areas that represent the storefront, product reviews, user account administration, and the purchasing system. Each area represents a separate function of the overall application.
This walkthrough demonstrates how to implement areas in an ASP.NET MVC application. The walkthrough creates the functional framework for a blog site that has the following areas:
  • Main. This is entry point to the Web application. This area includes the landing page and a log-in feature.
  • Blog. This area is used to display blog posts and to search the archive.
  • Dashboard. This area is used to create and edit blog posts.
To keep this tutorial simple, the areas do not contain logic to perform the actual tasks for the blog.
A Visual Studio project with source code is available to accompany this topic: Download.(MVC2的範例)

In order to complete this walkthrough, you will need:
  • Microsoft Visual Studio 2008 Service Pack 1 or Visual Web Developer 2008 Express Edition Service Pack 1, or a later version.
  • The ASP.NET MVC 2 framework. If you have installed Visual Studio 2010, the ASP.NET MVC 2 is already installed on your computer. To download the most up-to-date version of the framework, see the ASP.NET MVC download page.
This walkthrough assumes that you are familiar with ASP.NET MVC. For more information, see ASP.NET MVC 2(MSDN的MVC2).

To begin, you will create an ASP.NET MVC project and add the folder structure for two child areas (Blog and Dashboard).

To create the application structure

  1. In Visual Studio, in the File menu, and click New Project.
  2. In the Project types window, expand the Visual Basic node or the Visual C# node, and then select theWeb node.
  3. In the Templates window, select ASP.NET MVC 2 Web Application.
  4. Name the project MvcAreasApplication, set the project location, and then select the Create directory for solution check box.
  5. Click OK.
  6. In Solution Explorer, right-click the project name, click Add, and then click Area.
  7. In Area Name, type Blog and then click Add.
    An Areas folder is added to the project. The Areas folder contains a folder structure that allows each child area to have its own models, views, and controllers.
  8. In Solution Explorer, right-click the project name, click Add, and then click Area.
  9. In Area Name, enter Dashboard and then click Add.
    When you are done, the Areas folder contains two child areas, Blog and Dashboard.

You will now add area-enabled controllers and action methods for each area.

To add area controllers

  1. In Solution Explorer, right-click the Controllers subfolder for the Blog area, click Add, and then clickController.
  2. Name the controller BlogController and then click Add.
  3. Add the following code to the BlogController class.
    using System;  using System.Collections.Generic;  using System.Linq;  using System.Web;  using System.Web.Mvc;  using System.Web.Mvc.Ajax;    namespace MvcAreasApplication.Areas.Blog.Controllers  {      public class BlogController : Controller      {          public ActionResult ShowRecent()          {              return View();          }            public ActionResult ShowArchive()          {              return View();          }      }  }      
    This code creates two action methods named ShowRecent and ShowArchive. To keep this tutorial simple, the action methods do not contain logic to perform specific tasks.
  4. In the Dashboard area, right-click the Controllers subfolder, click Add, and then click Controller.
  5. Name the controller DashboardController and click Add.
  6. Add the following code to the DashboardController class.
    using System;  using System.Collections.Generic;  using System.Linq;  using System.Web;  using System.Web.Mvc;  using System.Web.Mvc.Ajax;    namespace MvcAreasApplication.Areas.Dashboard.Controllers  {      public class DashboardController : Controller      {          public ActionResult AddPost()          {              return View();          }            public ActionResult EditPost()          {              return View();          }      }  }      
    This code creates two action methods named AddPost and EditPost. To keep this tutorial simple, the action methods do not contain logic to perform specific tasks.

Next you will add area-enabled views for each action method.

To add area views

  1. Open the BlogController class, right-click inside the ShowRecent action method, click Add View, and then click Add.
  2. In the ShowRecent view, add the following markup to the page content after the header:
    <p><%= Html.ActionLink("Show Archive", "ShowArchive") %></p>  
    This markup creates a link to the ShowArchive action method that you created earlier.
  3. Right-click inside the ShowArchive method, click Add View, and then click Add.
  4. In the ShowArchive view, add the following markup to the page content after the header:
    <p><%= Html.ActionLink("Show Recent", "ShowRecent") %></p>  
  5. Open the DashboardController class, right-click inside the AddPost action method, click Add View, and then click Add.
  6. In the AddPost view, add the following markup to the page content after the header:
    <p><%= Html.ActionLink("Edit Post", "EditPost") %></p>  
  7. Right-click inside the EditPost method, click Add View, and then click Add.
  8. In the EditPost view, add the following markup to the page content after the header:
    <p><%= Html.ActionLink("Add Post", "AddPost") %></p>  

When you add an area to a project, a route for the area is defined in an AreaRegistration file. The route sends requests to the area based on the request URL. To register routes for areas, you add code to the Global.asax file that can automatically find the area routes in the AreaRegistration file.

To register area routes

  1. In Solution Explorer, open the Global.asax file for the project.
  2. Insert the following code into the Application_Start method:
      AreaRegistration.RegisterAllAreas();  
      AreaRegistration.RegisterAllAreas()  
    This code calls the route registration methods for each child area.

In an ASP.NET MVC area application, you can link within an area as you would in any MVC application. For example, you can call the ActionLink method, or you can call any other routine that takes a controller or action name (such as the RedirectToAction method).
However, to generate a link to a different area, you must explicitly pass the target area name in the routeValuesparameter for these methods. For example, the following markup shows a link to the ShowBlog action method ofBlogController class. This call does not identify a specific area.
<%= Html.ActionLink("Show Blog", "ShowBlog", "Blog") %>
The link will work as expected anywhere within the Blog area. However, if the preceding link is added to a view in the Dashboard area, it will fail. This is because the ASP.NET MVC framework would not be able to find theBlogController class in the Dashboard area.
The following example shows how to create a link that identifies the area in an anonymous object passed in therouteValues parameter. This example is shown only as an explanation. Do not add it to your project.
<%= Html.ActionLink("Show Blog", "ShowBlog", "Blog", new { area = "blog" }, null) %>  
NoteNote
The last null parameter (Nothing in Visual Basic) is required only because the ActionLink method overloads that have a routeValues parameter also have an htmlAttributes parameter. However, this parameter is not required in order to be able to link between areas.

Adding Content to the Main Project

When you created the Visual Studio solution for this walkthrough, the solution template included a master view that acts as the entry point for the application. In this section of the walkthrough, you will add tabs to the master view that link to the child areas. You will also add code to display diagnostic information, including the name of the controller, action method, and area that produced the current view.

To add content to the main project

  1. Open the master view (Views\Shared\Site.Master).
  2. Insert the following code directly after the <asp:ContentPlaceHolder ID="MainContent" runat="server" /> element.
    <p>      Controller: <%= ViewContext.RouteData.Values["controller"] %><br />      Action: <%= ViewContext.RouteData.Values["action"] %><br />      Area: <%= ViewContext.RouteData.DataTokens["area"] %>  </p>      
    This code adds diagnostic information to the views.
  3. In the same file, find the <ul id="menu"> element and replace the whole element with the following code:
    <ul id="menu">                    <li><%= Html.ActionLink("Home", "Index", "Home", new { area = "" }, null)%></li>      <li><%= Html.ActionLink("Blog", "ShowRecent", "Blog", new { area = "blog" }, null)%></li>      <li><%= Html.ActionLink("Dashboard", "AddPost", "Dashboard", new { area = "dashboard" }, null)%></li>      <li><%= Html.ActionLink("About", "About", "Home", new { area = "" }, null)%></li>  </ul>      
    This code adds tabs that link across areas.

Now you can build and test the application.

To build and run the application

  1. Click CTRL-F5 to build the solution and run the application.
    The default MVC template home page is displayed in the browser. The page shows the current controller (Home), the action that generated the page (Index), and the current area, which is blank and which indicates the main area.
  2. Click the Blog tab.
    The ShowBlog page is displayed. The ShowBlog page contains a link to the ShowArchive page. The current controller is changed to Blog. The action is ShowBlog, and the area is blog.
  3. Click Show Archive.
    Notice that the controller and area remain the same, but the action is now ShowArchive.
  4. Click the Dashboard tab.
    The AddPost page is displayed. The AddPost page contains a link to the EditPost page. The controller is now Dashboard, the action is AddPost, and the area is dashboard.
  5. Continue navigating the Web site and notice the changes to the controller, action, and area.

Other Resources


2013年8月9日 星期五

VM RHEL 5 安裝 yum 的過程

因為RHEL 5新安裝後, 出現
This system is not registered with RHN.
RHN support will be disabled.

第一步請先檢查你的RedHat的DNS解析是否有問題!! 如果不行再繼續往下.

沒有去處理官方的要求, 如果你有原版序號, 大概沒有這個問題, 因為這台沒有, 所以直接換成centos的yum組件.


0先檢查 /etc/yum.repos.d/rhel-debuginfo.repo 這個檔案,

原來的內容是:
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

我有把repo檔的內容載下來, 新的repo內容在最下面

注意,如果你的yum 可以 更新, eg: #yum update 可以執行, 下面的步驟就不用執行了


 1.卸载redhat的yum组件

# rpm -qa | grep yum | xargs rpm -e --nodeps

2.下載yum*.rpm 

到 rpm.pbone.net 這個網頁
eg:

(建了一個臨時的/usr/scource 下載需要的 rpm )
wget ftp://ftp.univie.ac.at/systems/linux/dag/redhat/el5/en/ppc/fabian/RPMS/yum-2.4.2-0.4.el5.rf.noarch.rpm

3.  安裝rpm

rpm -ivh yum-2.4.2-0.4.el5.rf.noarch.rpm
yum就正常可以使用了(版本2.4.2)

4.  更新yum

#yum install yum
更新到最新版

PS:補充 rhel-debuginfo.repo的內容 (來源 http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo )
rhel-debuginfo.repo

2013年8月1日 星期四

Organizing an ASP.NET MVC Application using Areas

The MVC pattern separates the model (data) logic of an application from its presentation logic and business logic. In ASP.NET MVC, this logical separation is also implemented physically in the project structure, where controllers and views are kept in folders that use naming conventions to define relationships. This structure supports the needs of most Web applications.
However, some applications can have a large number of controllers, and each controller can be associated with several views. For these types of applications, the default ASP.NET MVC project structure can become unwieldy.
To accommodate large projects, ASP.NET MVC lets you partition Web applications into smaller units that are referred to as areas. Areas provide a way to separate a large MVC Web application into smaller functional groupings. An area is effectively an MVC structure inside an application. An application could contain several MVC structures (areas).
For example, a single large e-commerce application might be divided into areas that represent the storefront, product reviews, user account administration, and the purchasing system. Each area represents a separate function of the overall application.
This walkthrough demonstrates how to implement areas in an ASP.NET MVC application. The walkthrough creates the functional framework for a blog site that has the following areas:
  • Main. This is entry point to the Web application. This area includes the landing page and a log-in feature.
  • Blog. This area is used to display blog posts and to search the archive.
  • Dashboard. This area is used to create and edit blog posts.
To keep this tutorial simple, the areas do not contain logic to perform the actual tasks for the blog.
A Visual Studio project with source code is available to accompany this topic: Download.

In order to complete this walkthrough, you will need:
  • Microsoft Visual Studio 2008 Service Pack 1 or Visual Web Developer 2008 Express Edition Service Pack 1, or a later version.
  • The ASP.NET MVC 2 framework. If you have installed Visual Studio 2010, the ASP.NET MVC 2 is already installed on your computer. To download the most up-to-date version of the framework, see the ASP.NET MVC download page.
This walkthrough assumes that you are familiar with ASP.NET MVC. For more information, see ASP.NET MVC 2.

To begin, you will create an ASP.NET MVC project and add the folder structure for two child areas (Blog and Dashboard).
To create the application structure
  1. In Visual Studio, in the File menu, and click New Project.
  2. In the Project types window, expand the Visual Basic node or the Visual C# node, and then select theWeb node.
  3. In the Templates window, select ASP.NET MVC 2 Web Application.
  4. Name the project MvcAreasApplication, set the project location, and then select the Create directory for solution check box.
  5. Click OK.
  6. In Solution Explorer, right-click the project name, click Add, and then click Area.
  7. In Area Name, type Blog and then click Add.
An Areas folder is added to the project. The Areas folder contains a folder structure that allows each child area to have its own models, views, and controllers.
  1. In Solution Explorer, right-click the project name, click Add, and then click Area.
  2. In Area Name, enter Dashboard and then click Add.
When you are done, the Areas folder contains two child areas, Blog and Dashboard.

You will now add area-enabled controllers and action methods for each area.
To add area controllers
  1. In Solution Explorer, right-click the Controllers subfolder for the Blog area, click Add, and then clickController.
  2. Name the controller BlogController and then click Add.
  3. Add the following code to the BlogController class.
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;

namespace MvcAreasApplication.Areas.Blog.Controllers
{
    public class BlogController : Controller
    {
        public ActionResult ShowRecent()
        {
            return View();
        }

        public ActionResult ShowArchive()
        {
            return View();
        }
    }
}


This code creates two action methods named ShowRecent and ShowArchive. To keep this tutorial simple, the action methods do not contain logic to perform specific tasks.
  1. In the Dashboard area, right-click the Controllers subfolder, click Add, and then click Controller.
  2. Name the controller DashboardController and click Add.
  3. Add the following code to the DashboardController class.
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;

namespace MvcAreasApplication.Areas.Dashboard.Controllers
{
    public class DashboardController : Controller
    {
        public ActionResult AddPost()
        {
            return View();
        }

        public ActionResult EditPost()
        {
            return View();
        }
    }
}

This code creates two action methods named AddPost and EditPost. To keep this tutorial simple, the action methods do not contain logic to perform specific tasks.

Next you will add area-enabled views for each action method.
To add area views
  1. Open the BlogController class, right-click inside the ShowRecent action method, click Add View, and then click Add.
  2. In the ShowRecent view, add the following markup to the page content after the header:
<p><%= Html.ActionLink("Show Archive", "ShowArchive") %></p>
This markup creates a link to the ShowArchive action method that you created earlier.
  1. Right-click inside the ShowArchive method, click Add View, and then click Add.
  2. In the ShowArchive view, add the following markup to the page content after the header:
<p><%= Html.ActionLink("Show Recent", "ShowRecent") %></p>
  1. Open the DashboardController class, right-click inside the AddPost action method, click Add View, and then click Add.
  2. In the AddPost view, add the following markup to the page content after the header:
<p><%= Html.ActionLink("Edit Post", "EditPost") %></p>
  1. Right-click inside the EditPost method, click Add View, and then click Add.
  2. In the EditPost view, add the following markup to the page content after the header:
<p><%= Html.ActionLink("Add Post", "AddPost") %></p>

When you add an area to a project, a route for the area is defined in an AreaRegistration file. The route sends requests to the area based on the request URL. To register routes for areas, you add code to the Global.asax file that can automatically find the area routes in the AreaRegistration file.
(jk:這段是說每一個Area都會有一個AreaRegistration.cs的檔案(會有一個AreaRegistration的類別),會註冊路由…)
To register area routes
  1. In Solution Explorer, open the Global.asax file for the project.
  2. Insert the following code into the Application_Start method:
C#
AreaRegistration.RegisterAllAreas();
VB
AreaRegistration.RegisterAllAreas()
This code calls the route registration methods for each child area.

In an ASP.NET MVC area application, you can link within an area as you would in any MVC application. For example, you can call the ActionLink method, or you can call any other routine that takes a controller or action name (such as the RedirectToAction method).
However, to generate a link to a different area, you must explicitly pass the target area name in the routeValues parameter for these methods. For example, the following markup shows a link to the ShowBlog action method of BlogController class. This call does not identify a specific area.
<%= Html.ActionLink("Show Blog", "ShowBlog", "Blog") %>
The link will work as expected anywhere within the Blog area(Blogarea內是正確的). However, if the preceding link is added to a view in the Dashboard area, it will fail. This is because the ASP.NET MVC framework would not be able to find the BlogController class in the Dashboard area.
The following example shows how to create a link that identifies the area in an anonymous object passed in the routeValues  parameter. This example is shown only as an explanation. Do not add it to your project.
(jk: Html.ActionLink共有10Overload主要是要給linkText actionName)
(jk: 如果要產生不同area的連結,就一定要給目地的area名稱在routeValues的參數內)
C#
<%= Html.ActionLink("Show Blog", "ShowBlog", "Blog", new { area = "blog" }, null) %>
NoteNote
The last  null  parameter (Nothing  in Visual Basic) is required only because the  ActionLink  method overloads that have a  routeValues  parameter also have an  htmlAttributes  parameter. However, this parameter is not required in order to be able to link between areas.
Adding Content to the Main Project
When you created the Visual Studio solution for this walkthrough, the solution template included a master view that acts as the entry point for the application. In this section of the walkthrough, you will add tabs to the master view that link to the child areas. You will also add code to display diagnostic information, including the name of the controller, action method, and area that produced the current view.
To add content to the main project
  1. Open the master view (Views\Shared\Site.Master).
  2. Insert the following code directly after the <asp:ContentPlaceHolder ID="MainContent" runat="server" /> element.
C#
<p>
    Controller: <%= ViewContext.RouteData.Values["controller"] %><br />
    Action: <%= ViewContext.RouteData.Values["action"] %><br />
    Area: <%= ViewContext.RouteData.DataTokens["area"] %>
</p>


This code adds diagnostic information to the views.
  1. In the same file, find the <ul id="menu"> element and replace the whole element with the following code:
C#
<ul id="menu">             
    <li><%= Html.ActionLink("Home", "Index", "Home", new { area = "" }, null)%></li>
    <li><%= Html.ActionLink("Blog", "ShowRecent", "Blog", new { area = "blog" }, null)%></li>
    <li><%= Html.ActionLink("Dashboard", "AddPost", "Dashboard", new { area = "dashboard" }, null)%></li>
    <li><%= Html.ActionLink("About", "About", "Home", new { area = "" }, null)%></li>
</ul>


This code adds tabs that link across areas.

Now you can build and test the application.
To build and run the application
  1. Click CTRL-F5 to build the solution and run the application.
The default MVC template home page is displayed in the browser. The page shows the current controller (Home), the action that generated the page (Index), and the current area, which is blank and which indicates the main area.
  1. Click the Blog tab.
The ShowBlog page is displayed. The ShowBlog page contains a link to the ShowArchive page. The current controller is changed to Blog. The action is ShowBlog, and the area is blog.
  1. Click Show Archive.
Notice that the controller and area remain the same, but the action is now ShowArchive.
  1. Click the Dashboard tab.
The AddPost page is displayed. The AddPost page contains a link to the EditPost page. The controller is now Dashboard, the action is AddPost, and the area is dashboard.
  1. Continue navigating the Web site and notice the changes to the controller, action, and area.

Other Resources