After extensively researching and trying multiple examples, I am still facing an issue with my application.
I have a similar problem to this post on Stack Overflow, but the solution provided there is not working for me either.
This is the overall structure of my application:
https://i.sstatic.net/dsw6V.png
And this is the structure specific to the ADMIN AREA:
https://i.sstatic.net/NcAEp.png
The project consists of two separate applications - one for clients and one for admins. The admin section is managed through Areas.
I am using Angular 1.3.5 within the Areas.
The landing page is the index page of the Home Controller path: Areas/Admin/Views/Home/Index.cshtml
The layout is located at _Layout Path: Areas/Admin/Views/Shared/_Layout.cshtml
In the RouteConfig.cs file inside the App_Start folder:
namespace StockManagment
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces : new []{"StockManagment.Controllers"}
);
}
}
}
AdminAreaRegistration.cs:
namespace StockManagment.Areas.Admin
{
public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional },
new [] {"StockManagment.Areas.Admin.Controllers"}
);
}
}
}
Enabled HTML5MODE to remove "#" from the URL
myApp.config(["$locationProvider", function ($locationProvider) {
$locationProvider.html5Mode(true);
}]);
Added Base Tag in the _Layout Page:
<base href="/">
Web.config Code For Admin Areas:
<rewrite>
<rules>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
When attempting to access the admin side using this URL: http://localhost:8917/Admin/Home/Index
The website loads at localhost:8917/, and upon refreshing the page, it reverts back to the client-side home page content.
I seem to have missed something crucial in my implementation. Help would be greatly appreciated!
Edit 1:
I removed the rewrite code in web.config as I used it based on another post's suggestion.
Prior to using the following code:
myApp.config(["$locationProvider", function ($locationProvider) {
$locationProvider.html5Mode(true);
}]);
and
<base href="@Request.Url.AbsolutePath" />
To access the admin side homepage, the URL was: http://localhost:8917/Admin/Home/Index#/
After implementing the above code, the URL now reads: http://localhost:8917/Admin/Home/
Accessing the categories page:
Before the code adjustments, the URL was: http://localhost:8917/Admin/Home/Index#/Categories
Post changes, the URL became: http://localhost:8917/Admin/Home/Categories
However, upon refreshing the page, an error occurs:
Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or temporarily unavailable. Please ensure that the URL is correctly spelled.
Requested URL: /Admin/Home/Categories