private void LoadedPageHandler(object sender, PageEventArgs pageEventArgs) { var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>(); using (var file = new System.IO.StreamWriter(@"C:\ESDebug\LoadedPage.txt", true)) { file.WriteLine("Event Loaded page: " + urlResolver.GetVirtualPath(pageEventArgs.Page.ContentLink, pageEventArgs.Page.LanguageBranch)); } }
} }
Uninitialize(), Preload(), etc are removed to keep post size down.
The file output is just there for debugging (was added late and is not the problem itself...)
I have tried using both pageEventArgs.Page.ContentLink, pageEventArgs.ContentLink, pageEventArgs.PageLink, all to no avail. Same result regardless. Attaching with VS gives the same result as well.
GetVirtualPath returns null.
If I put the same 5 lines into a controller it gives me the path.
I'm using the LoadedPage event only as a test, I intend to use other events but picked that one because it triggers just by browsing in.
Can someone tell me what I'm doing wrong or if you want some more data?
Hi all!
I have not developed for EPiServer before and am running into a problem which hopefully is something silly that I can laugh about all weekend long.
Here's an excerpt of my class:
namespace MyNamespace
{
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class MyClass : IInitializableModule
{
private bool _eventsAttached = false;
public void Initialize(InitializationEngine context)
{
if (_eventsAttached) return;
DataFactory.Instance.LoadedPage += LoadedPageHandler;
_eventsAttached = true;
}
private void LoadedPageHandler(object sender, PageEventArgs pageEventArgs)
{
var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
using (var file = new System.IO.StreamWriter(@"C:\ESDebug\LoadedPage.txt", true))
{
file.WriteLine("Event Loaded page: " + urlResolver.GetVirtualPath(pageEventArgs.Page.ContentLink, pageEventArgs.Page.LanguageBranch));
}
}
}
}
Uninitialize(), Preload(), etc are removed to keep post size down.
The file output is just there for debugging (was added late and is not the problem itself...)
I have tried using both pageEventArgs.Page.ContentLink, pageEventArgs.ContentLink, pageEventArgs.PageLink, all to no avail. Same result regardless. Attaching with VS gives the same result as well.
GetVirtualPath returns null.
If I put the same 5 lines into a controller it gives me the path.
I'm using the LoadedPage event only as a test, I intend to use other events but picked that one because it triggers just by browsing in.
Can someone tell me what I'm doing wrong or if you want some more data?
Thanx
// Stefan