MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

Accessing Application Page through code

  Asked By: Staci    Date: Sep 23    Category: MOSS    Views: 890

Can I access a custom Application page (deployed in Layouts folder of
12 hive) through code and call its Page_Load and other events? I tried
searching a lot, but found no results. I am trying to use
HttpContext.Current. I can use this only in an Application Page and not in a
custom Windows or Console application with System.Web reference, to get the
actual share point context. I can't use SPContext here, unless I can convert
SPContext to HttpContext. I don't need the UI for the application page. I
only need to call it through code in the context of any Share Point web
application. Any help would be appreciated.



6 Answers Found

Answer #1    Answered By: Heena Nagori     Answered On: Sep 23

If you are in a windows app or a console app there is by definition NO
HttpContext. HttpContext is only available when you make a request to an
IIS server for a web page. Outside of that request there is no context.
Depending on what you want to get from the context there are other ways to
instantiate SharePoint objects. In a windows or console app you need to use
them. Also, the Page Load event of a web page is not something you can
call. It is raised by the IIS server when the page is loaded.

Tell us what are you trying to do and we can try to help.

Answer #2    Answered By: Aishwarya Karmarkar     Answered On: Sep 23

I want to get all the output
cache values using the following syntax at the level of every site


and then remove the cache for an individual item by passing its key with the
following syntax.


I can't use this in a console / windows / web application. So I thought I
would put this in a custom application page and would call this page through
code from a console / windows application. Also, this needs to be executed
for every load balanced server in the farm.

Answer #3    Answered By: Janell Camacho     Answered On: Sep 23

As I've already said. If the cache is properly configured you shouldn't
need to invalidate it when you push new content. Rather than spending a
lot of time trying to jump through hoops to invalidate the cache why don't
you look at how its configured and get it configured correctly. Then the
extra programming won't be necessary.

Answer #4    Answered By: Julia Washington     Answered On: Sep 23

This a shot in the dark here, but it sounds to me like you should really
be extracting whatever code the you have in that Application Page to
some other module so that it can be called from multiple places...

Answer #5    Answered By: Shashwat Takle     Answered On: Sep 23

Go grab the file from the server and mimic its functionality on
your own page...I like it!

Answer #6    Answered By: Aastha Acharya     Answered On: Sep 23

you sure you don't work for Microsoft technical support? Your questions
are always very detailed and have nuances that are rarely encountered on a
day-to-day basis...yet you seem to have them a lot. You must have some really
large-scale projects with a bunch of developers?

Didn't find what you were looking for? Find more on Accessing Application Page through code Or get search suggestion and latest updates.