I have created an MVC area in the solution:
Areas |_ CAG |_ Controllers |_ Models |_ Views
When published, the Areas
folder goes into the root of the instance's webroot.
Here is the Area registration:
public class CAGAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "CAG";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
//to load default page when the url is '<instance>/ContentAuthoringGuide
context.MapRoute(
"CAG_Home",
"CAG/{id}",
new { controller = "CAG", action = "Index", id = UrlParameter.Optional }
);
context.MapRoute(
"CAG_default",
"CAG/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}
The page URL will be https://myproject/CAG/{item-id}
This is not a Sitecore page item
In the Index method of the Controller, I can access the Sitecore items.
But here Sitecore.Context.IsLoggedIn
always returns false.
public ActionResult Index(string id)
{
bool isLoggedIn = Sitecore.Context.IsLoggedIn;
var contextSite = Sitecore.Context.Site; //returns "website"
}
I have not created any patch configs.
Using Sitecore 10.1.2
Sitecore.Context.User
,Sitecore.Context.User.IsAuthenticated
,Sitecore.Context.User.IsNullOrAnonymous()
. DoesIsLoggedIn
return the results you expect at theHttpRequestProcessor
level?extranet\anonymous
.