We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Action in the same area is not working

Hi,

Failed to load resource: the server responded with a status of 404 ()


Admin area - View is Index

<ejs-grid id="filesSearchGrid" ... >
    <e-data-manager url="@Url.Action("GetFilesForAdmin", "Test", new { Area = "" })" adaptor="UrlAdaptor"></e-data-manager>


3 Replies

PS Pavithra Subramaniyam Syncfusion Team November 20, 2019 09:40 AM UTC

Hi John, 
 
Thanks for contacting Syncfusion support. 
 
We could see that you want sent a request by using Areas property and you can achieve your requirement by setting the routing in startup.cs file. 
 
 We have created the sample by following the steps in the documentation , in which we have sent a request to the Home1 Controller under Products  Area by adding route ( areaName: "Products" ) in the startup.cs file. Please refer the below code example, sample and screenshot for information. 
 
Index.cshtml 
 
<ejs-grid id="Grid" allowPaging="true" allowSorting="true" allowFiltering="true" toolbar="@(new List<string>() {"Search" })"> 
    <e-data-manager url="@Url.Action("UrlDatasource", "Home1",new { Area = "" })" adaptor="UrlAdaptor"></e-data-manager> 
------------ 
</ejs-grid> 
  
Areas/Products/Controllers/Home1 
 
namespace WebApplication7.Controllers 
{ 
    [Area("Products")] 
    public class Home1Controller : Controller 
    { 
        ------------ 
    } 
     public IActionResult UrlDatasource([FromBody]DataManagerRequest dm) 
        { 
            IEnumerable DataSource = OrdersDetails.GetAllRecords(); 
            ----------- 
            return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource); 
        } 
} 
 
Startup.cs 
 
public void Configure(IApplicationBuilder app, IHostingEnvironment env){ 
app.UseMvc(routes => 
            { 
                routes.MapAreaRoute( 
           name: "MyAreaProducts", 
           areaName: "Products",     // here you have to add your areaName where to fetch 
 
           template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"); 
 
                routes.MapAreaRoute( 
                    name: "MyAreaServices", 
                    areaName: "Services", 
                    template: "Services/{controller=Home}/{action=Index}/{id?}"); 
                routes.MapRoute( 
                    name: "default", 
                    template: "{controller=Home}/{action=Index}/{id?}"); 
            }); 
} 
 
Screenshot:  
 
 
 
 
 
Please get back to us, if you need further assistance. 
 
Regards, 
Pavithra S. 
 



JS John Stephen Mangam November 20, 2019 11:42 AM UTC

Hi,

I'm using asp.net core 3.0

My startup code is:

 app.UseEndpoints(routes =>
            {
...
                  routes.MapAreaControllerRoute(
                    "Admin",
                    "Admin",
                    "Admin/{controller=Home}/{action=Index}/{id?}");
...


PS Pavithra Subramaniyam Syncfusion Team November 21, 2019 12:46 PM UTC

Hi John, 
 
Thanks for your update. 
 
We have validated the provide details and created the sample with version ASP.Net Core 3.0. In that we have sent a request to the Home1 Controller under Products in Areas by adding route ( areaName: "Products" ) in the startup.cs file. Please refer the below code example and sample for information. 
 
Index.cshtml 
 
<ejs-grid id="Grid" allowPaging="true" allowSorting="true" allowFiltering="true" toolbar="@(new List<string>() {"Search" })"> 
    <e-data-manager url="@Url.Action("UrlDatasource", "Home1",new { Area = "" })" adaptor="UrlAdaptor"></e-data-manager> 
------------ 
</ejs-grid> 
  
Areas/Products/Controllers/Home1 
 
namespace WebApplication7.Controllers 
{ 
    [Area("Products")] 
 
    public class Home1Controller : Controller 
    { 
        ------------ 
    } 
     public IActionResult UrlDatasource([FromBody]DataManagerRequest dm) 
        { 
            IEnumerable DataSource = OrdersDetails.GetAllRecords(); 
            ----------- 
            return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource); 
        } 
} 
 
Startup.cs 
 
public void Configure(IApplicationBuilder app, IWebHostEnvironment env){ 
-------- 
app.UseEndpoints(endpoints => 
            { 
                endpoints.MapControllers(); 
                endpoints.MapAreaControllerRoute( 
                    "Products", 
                    "Products",  // here you have to set your area name 
                    "{area:exists}/{controller=Home}/{action=Index}/{id?}"); 
                endpoints.MapControllerRoute( 
                    "default", "{controller=Home}/{action=Index}/{id?}"); 
                endpoints.MapControllerRoute( 
                    name: "default", 
                    pattern: "{controller=Home}/{action=Index}/{id?}"); 
            }); 
} 
 
 
Please get back to us, if you need further assistance. 
 
Regards, 
Pavithra S. 


Loader.
Up arrow icon