Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2004, 03:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default Request Namespace

What namespace is Request a member of?

I'm trying to use it in a shared function but can't figure out what namespace it is in.

dim myip = Request.ServerVariables("REMOTE_ADDR")

Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.


 
Old January 28th, 2004, 03:41 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

The HttpRequest class lives in the System.Web namespace, so you'll need to import that namespace.

http://msdn.microsoft.com/library/de...classtopic.asp

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 28th, 2004, 03:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

hmmmm.... I tried that earlier.

When I added Dim myip = System.Web.HttpRequest.ServerVariables("REMOTE_ADD R")

I get Reference to a non-shared member requires an object reference.


 
Old January 28th, 2004, 04:47 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yeah, that makes sense. I didn't provide all the necessary information. My bad.

By default, your Class Library, or wherever you stored your other class, is not aware of a Web environment. However, the System.Web namespace exposes a HttpContext class. This class has a Current property that returns information about the current (duh) HTTP Request. From this Current property, you can then retrieve stuff like Request, Cache, Session, etc. For example:
Code:
string myQS = System.Web.HttpContext.Current.Request.QueryString["MyString"];
Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 28th, 2004, 05:27 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

That worked.

Thanks.






Similar Threads
Thread Thread Starter Forum Replies Last Post
request forwarging & request redirection hafizmuhammadmushtaq Servlets 2 April 24th, 2008 12:42 AM
namespace Tomi XML 0 September 14th, 2007 04:39 AM
Request.Form / Request.QueryString Toran Classic ASP Databases 4 January 17th, 2007 02:23 PM
request.qurystring vs. request.form Durwood Edwards Classic ASP Databases 3 June 18th, 2004 12:09 AM
request.querystring() , request.form() alyeng2000 ASP.NET 1.0 and 1.1 Basics 1 December 30th, 2003 12:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.