- Home
- Forum
- ASP.NET Core - EJ 2
- Action in the same area is not working
Action in the same area is not working
Hi,
Failed to load resource: the server responded with a status of 404 ()
It is trying to reach https://localhost:44358/Test/GetFilesForAdmin instead of https://localhost:44358/Admin/Test/GetFilesForAdmin
Admin area - View is Index
<ejs-grid id="filesSearchGrid" ... >
<e-data-manager url="@Url.Action("GetFilesForAdmin", "Test", new { Area = "" })" adaptor="UrlAdaptor"></e-data-manager>
SIGN IN To post a reply.
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:
Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/request_with_areas_core893369030
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?}");
});
} |
Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/request_to_areas_3.02129247140
Please get back to us, if you need further assistance.
Regards,
Pavithra S.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
JS John Stephen Mangam
- Nov 19, 2019 10:50 AM UTC
- Nov 21, 2019 12:46 PM UTC