Search code examples
aspnetboilerplate

ASP.NET Zero: How to add new Area in another project?


I have created a modular application based on Zero Framework following this tutorial Because that tut didn't guide to create an Area in module Web. So I decided to create another area (named Payment) in root web project.

  1. Areas/F1 <--my default area
  2. Areas/Payment <--new area

I created a very simple controller (inherited from project controller base class) like this:

 public class BankCodeController : FastOneControllerBase
    {
        // GET: Payment/BankCode
        public ActionResult Index()
        {
            return View();
        }
    }

...and my Index.cshtml

@using FastOne.Web.Navigation
@{
    ViewBag.CurrentPageName = PageNames.App.Payment.BankCode;
}
<div class="row margin-bottom-5">
    <div class="col-xs-12">
        <div class="page-head">
            <div class="page-title">
                <h1>
                    <span>BankCode</span>
                </h1>
            </div>
        </div>
    </div>
</div>

<div class="portlet light">
    <div class="portlet-body">
        <p>BANK CODE CONTENT COMES HERE!</p>
    </div>
</div>

But I faced the error as below when I tried to access that view

The controller for path '/Payment/BankCode' was not found or does not implement IController.

> Line 40:     @RenderSection("Styles", false) 
> Line 41:      
> Line 42:     @Html.Action("TenantCustomCss", "Layout") 
> Line 43:  
> Line 44:     <script type="text/javascript">

Hope anyone could help me on this error some guide to create this Area in module Web project (in the tutorial). Thanksss


Solution

  • Update

    I found this solution in ASPNET Zero forum

    Since I use _Layout.cshtml of F1 area, this error happens. I fixed it by adding F1 area name to @Html.Action usages in _Layout.cshtml.

    For example

    @Html.Action("Header", "Layout") becomes @Html.Action("Header", "Layout", new { area = "F1" })
    @Html.Action("Sidebar", "Layout", new { currentPageName = ViewBag.CurrentPageName }) becomes @Html.Action("Sidebar", "Layout", new { currentPageName = ViewBag.CurrentPageName, area = "F1" })