473,383 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How do I access 'Request' from a Library?

In one of my business objects I wanted to include a method like this:

public static void PageRedirect(string pageName)
{
Response.Redirect(Request.ApplicationPath + "/" + pageName);
}

The class is referencing 'System.Web' but yet I'm getting a compile error in
regard to "Request". How come this method works if sitting in the aspx.cs
file but not in the cs file in my business object?
--
Robert W.
Vancouver, BC
www.mwtech.com

Apr 27 '06 #1
4 1015
yep, encountered this problem yesterday. If not executed directly as a
page, need to use.

Imports System.Web

HttpContext.Current.Request.ApplicationPath

HttpContext.Current.Response.Redirect

Apr 28 '06 #2
Excellent. Thanks!!!

--
Robert W.
Vancouver, BC
www.mwtech.com

"te***@yahoo.com" wrote:
yep, encountered this problem yesterday. If not executed directly as a
page, need to use.

Imports System.Web

HttpContext.Current.Request.ApplicationPath

HttpContext.Current.Response.Redirect

Apr 28 '06 #3
Thus wrote Robert W.,
In one of my business objects I wanted to include a method like this:

public static void PageRedirect(string pageName)
{
Response.Redirect(Request.ApplicationPath + "/" + pageName);
}
The class is referencing 'System.Web' but yet I'm getting a compile
error in regard to "Request". How come this method works if sitting
in the aspx.cs file but not in the cs file in my business object?


The reason you can easily access Request, Response and other intrinsic objects
is that these are properties of the Page class. If you want to use them in
a library, you'll have to pass them as method parameters.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Apr 28 '06 #4
Thus wrote Joerg,
The reason you can easily access Request, Response and other intrinsic
objects is that these are properties of the Page class. If you want to
use them in a library, you'll have to pass them as method parameters.


I shouldn't have said "have to" -- of course one can use HttpContext.Current
to grab the intrinsics, but I usually prefer to use rather explicit interfaces
and not rely on magic (i.e. runtime or host dependent) static members.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Apr 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Aprochko | last post by:
Attempting to access outlook from C# .NET ASP app. Have added reference to COM Microsoft Outlook 11 Object Library. Have included using System.Runtime.InteropServices; using System.Web.Mail;...
0
by: pottschmidtr | last post by:
I receive the following error 'Request for the permission of type System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral,...
4
by: Fabian von Romberg | last post by:
Hi, I have installed Sql Reporting Services on 2 machines, one is WIN 2000 PRO and the other one is WIN 2000 ADV. SERVER. When I try to access a report using the webbrowser, I get the following...
2
by: Phil Ten | last post by:
Hello, I am working on a .NET C++ project based on the "Class Library (.NET)" wizard of Visual Studio .NET 2003. I would like to know if my .NET component is running in a ASP.NET page (.apsx...
10
by: Shawn | last post by:
JIT Debugging failed with the following error: Access is denied. JIT Debugging was initiated by the following account 'PLISKEN\ASPNET' I get this messag in a dialog window when I try to open an...
0
by: sudosue | last post by:
I have a systems analyst who came to me with a problem with retrieving a PDF file from a clients website. I've reduced the explaination to the bare facts thus if you need more information just let...
1
by: cpajoe2001 | last post by:
I am having an issue and after searching around online for a day and half now and finding others with the same problem but yet no solution to my issue I am looking for help. What i have is ServerA...
5
by: =?Utf-8?B?SSBhbSBTYW0=?= | last post by:
Hello everyone, It has been a while and I need some help. I need to access specific information on a third party web site and return that specific information on a web site I am working on. Is...
1
by: rajalingam | last post by:
Server Error in '/library' Application. -------------------------------------------------------------------------------- Server cannot access application directory 'F:\Library Latest Code\'. The...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.