Front Controller testing

M

Matt

Hi All.
I have been trying to implement this front controller On MS site and
finally i have no error on the pages but i dont its working or not.
When i execute the pages from Browser i dont get no result. I have hard
coded the Database getting site name part still no luck.
I have try to write the context that i am passing, seems empty.
If someone pls help me out with testing this i would appriciate it.
May be someone can post the working code here. or tell me what am i
doing wrong
This is how i call it
http://localhost/XFrontController/actualpage1.aspx

actualpage1.aspx
public class actualpage1.aspx : BasePage
{
protected System.Web.UI.WebControls.Label pageNumber;

protected override void PageLoadEvent(object sender, System.EventArgs
e)
{
pageNumber.Text = "Overloaded 1";
}

}
BasePage.cs
protected Label eMail;
protected Label siteName;
virtual protected void PageLoadEvent(object sender, System.EventArgs e)
{}
protected void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
eMail.Text = (string)Context.Items["address"];
siteName.Text = (string)Context.Items["site"];
PageLoadEvent(sender, e);
}
}

Handler.cs
public class Handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
Command command = CommandFactory.Make(context.Request.Params);
command.Execute(context); }
public bool IsReusable
{get { return true;} }
}
Command.cs, same execute interface
CommandFactory.Cs
public class CommandFactory
{
public static Command Make(NameValueCollection parms)
{
string siteName = parms["site"];

Command command = new UnknownCommand();
if(siteName == null || siteName.Equals("micro"))
command = new MicroSite();
else if(siteName.Equals("macro"))
command = new MacroSite();
return command;
}
}

,redirectCommand.cs
these class are same as MS site.

WebConfig

<configSections>
<section name="commandSettings" type="UrlMap,XFrontController" />
</configSections>

<commandSettings>
<entries>
<entry key="/XFrontController/ActualPage1.aspx"
url="ActualPage1.aspx" />
<entry key="/XFrontController/ActualPage2.aspx"
url="ActualPage2.aspx" />
</entries>
</commandSettings>

<system.web>

<httpHandlers>
<add verb="*" path="Page*.aspx" type="Handler,IAFrontController" />
</httpHandlers>

MacroSite and MicroSite.cs i have hardCode the call

public class MacroSite : RedirectingCommand
{
protected override void OnExecute(HttpContext context)
{
string name = context.User.Identity.Name;

context.Items["address"] =
"macro";//MacroUsersDatabase.RetrieveAddress(name);
context.Items["site"] = "Macro-Site";
}
}

public class MicroSite : RedirectingCommand
{
protected override void OnExecute(HttpContext context)
{
string name = context.User.Identity.Name;

context.Items["address"] = "micro"; //
WebUsersDatabase.RetrieveAddress(name);
context.Items["site"] = "Micro-Site";
}
}

I did not change
RedirectingCommand,UrlMap,
public class UnknownCommand : RedirectingCommand
{
protected override void OnExecute(HttpContext context)
{
string name = context.User.Identity.Name;
context.Items["address"] = "user " + name + " is unknown";
context.Items["site"] = "Unknown";
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top