Getting a Reference to the WebForms from a Class

  • Thread starter Thread starter Matthew Sajdera
  • Start date Start date
M

Matthew Sajdera

All -

What I want to do:

I want to abstract the navigation between my aspx pages into a Controlling
Class. This Class would talk to a collection of Business Objects. The
various aspx pages would make calls to the Controlling Class which would, in
turn, make the necessary calls to the Business Objects. Depending on what
page you are on and the returns from the Business Objects, the Controlling
Class will navigate the user to the correct page.

Problem I'm having:

I cannot seem to figure out how I get a reference to the context of the
pages from the Controlling Class. From the Controlling Class I am unable to
Redirect the user to another page, because I can't even get a good reference
to the Response object.

All help is appreciated.

Thanks,

- Matt
 
All -

I have found the answer:
HttpContext.Current.Response.Redirect
HttpContext.Currect will give you a link to the currect page.

Thanks,

- Matt
 
Matthew said:
All -

What I want to do:

I want to abstract the navigation between my aspx pages into a Controlling
Class. This Class would talk to a collection of Business Objects. The
various aspx pages would make calls to the Controlling Class which would, in
turn, make the necessary calls to the Business Objects. Depending on what
Problem I'm having:

I cannot seem to figure out how I get a reference to the context of the
pages from the Controlling Class. From the Controlling Class I am unable to

The quick answer is to use System.Web.HttpContext.Current.Response, etc.
which gets you a reference to the current HTTP context from any class
loaded in ASP.NET.

Looks like you're looking for a more-pure J2EE kind of MVC layout.
There's an example of a .NET app written to mock J2EE, I haven't looked
at it myself, but may have a design pattern for you to follow:

http://www.gotdotnet.com/team/compare/petshop.aspx
 
Craig said:
The quick answer is to use System.Web.HttpContext.Current.Response, etc.
which gets you a reference to the current HTTP context from any class
loaded in ASP.NET.

Looks like you're looking for a more-pure J2EE kind of MVC layout.
There's an example of a .NET app written to mock J2EE, I haven't looked
at it myself, but may have a design pattern for you to follow:

http://www.gotdotnet.com/team/compare/petshop.aspx

I should say that this sample app's purpose was not to mock per se, it
was to create a comparable app for performance testing purposes. It may
or may not be modeled the same way.
 
Hi Matt,

Here are some further resources on the Microsoft Enterprise Design Patterns:

#Web Presentation Patterns
http://msdn.microsoft.com/library/en-us/dnpatterns/html/EspWebPresentationPa
tterns.asp?frame=true

Hope also helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

-------------------------------------------------------------------------
 
Back
Top