473,385 Members | 1,409 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,385 software developers and data experts.

Request Object Bombs-Out Class File

I'm using the intrinsic Request object wrong and need some help with this
one. I wrote a class file for some XMLTextWriter tasks and in the class file
I want to use a conditional to determine if the application is running on
the host provider's web server or the web server on my local development
machine. Here is my broken code...

string fileOut;
// Run-time: running on host provider's server
if(Request.ServerVariables["LOCAL_ADDR"] == "XXX.XXX.XXX.XX")
fileOut = HttpContext.Current.Server.MapPath("filename.xml") ;
else
// Design-time: running on local development server
fileOut = HttpContext.Current.Server.MapPath("filename.xml") ;

What do I need to change or add to the code in this class file to use the
Request object? Thanks for comments...

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
Nov 16 '05 #1
4 3381
As long as you have access to your statics... Not sure where you are making
your calls from though. That may also be inaccessible or null.

HttpContext.Current.Request
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm using the intrinsic Request object wrong and need some help with this
one. I wrote a class file for some XMLTextWriter tasks and in the class file
I want to use a conditional to determine if the application is running on
the host provider's web server or the web server on my local development
machine. Here is my broken code...

string fileOut;
// Run-time: running on host provider's server
if(Request.ServerVariables["LOCAL_ADDR"] == "XXX.XXX.XXX.XX")
fileOut = HttpContext.Current.Server.MapPath("filename.xml") ;
else
// Design-time: running on local development server
fileOut = HttpContext.Current.Server.MapPath("filename.xml") ;

What do I need to change or add to the code in this class file to use the
Request object? Thanks for comments...

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

Nov 16 '05 #2
I'm gonna guess that you defining a class in an assembly that's outside
your web project. Which is fine, except that VisualStudio doesn't
automatically add the reference to the System.Web for you. You have to do
that yourself.

--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm using the intrinsic Request object wrong and need some help with this
one. I wrote a class file for some XMLTextWriter tasks and in the class file I want to use a conditional to determine if the application is running on
the host provider's web server or the web server on my local development
machine. Here is my broken code...

string fileOut;
// Run-time: running on host provider's server
if(Request.ServerVariables["LOCAL_ADDR"] == "XXX.XXX.XXX.XX")
fileOut = HttpContext.Current.Server.MapPath("filename.xml") ;
else
// Design-time: running on local development server
fileOut = HttpContext.Current.Server.MapPath("filename.xml") ;

What do I need to change or add to the code in this class file to use the
Request object? Thanks for comments...

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

Nov 16 '05 #3
Thanks Justin. I was 'using' System.Web but declaring the
HttpContext.Current.Request seems to have stopped the compiler from
complaining.

<%= Clinton Gallagher
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:e5**************@tk2msftngp13.phx.gbl...
As long as you have access to your statics... Not sure where you are making your calls from though. That may also be inaccessible or null.

HttpContext.Current.Request
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm using the intrinsic Request object wrong and need some help with this one. I wrote a class file for some XMLTextWriter tasks and in the class file I want to use a conditional to determine if the application is running on the host provider's web server or the web server on my local development
machine. Here is my broken code...

string fileOut;
// Run-time: running on host provider's server
if(Request.ServerVariables["LOCAL_ADDR"] == "XXX.XXX.XXX.XX")
fileOut = HttpContext.Current.Server.MapPath("filename.xml") ;
else
// Design-time: running on local development server
fileOut = HttpContext.Current.Server.MapPath("filename.xml") ;

What do I need to change or add to the code in this class file to use the Request object? Thanks for comments...

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/


Nov 16 '05 #4
Thanks for comments James. The class file is in the same project. It looks
like Justin's suggestion to declare the use
of HttpContext.Current.Request resolved the problem.

<%= Clinton Gallagher

"James Curran" <Ja*********@mvps.org> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I'm gonna guess that you defining a class in an assembly that's outside your web project. Which is fine, except that VisualStudio doesn't
automatically add the reference to the System.Web for you. You have to do
that yourself.

--
Truth,
James Curran
[erstwhile VC++ MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm using the intrinsic Request object wrong and need some help with this one. I wrote a class file for some XMLTextWriter tasks and in the class

file
I want to use a conditional to determine if the application is running on the host provider's web server or the web server on my local development
machine. Here is my broken code...

string fileOut;
// Run-time: running on host provider's server
if(Request.ServerVariables["LOCAL_ADDR"] == "XXX.XXX.XXX.XX")
fileOut = HttpContext.Current.Server.MapPath("filename.xml") ;
else
// Design-time: running on local development server
fileOut = HttpContext.Current.Server.MapPath("filename.xml") ;

What do I need to change or add to the code in this class file to use the Request object? Thanks for comments...

--
<%= Clinton Gallagher, "Twice the Results -- Half the Cost"
Architectural & e-Business Consulting -- Software Development
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/


Nov 16 '05 #5

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

Similar topics

0
by: Punisher | last post by:
I have a method that does this: General_DataGrid gdgCurrentItem = new General_DataGrid(); Page.Controls.Add(gdgCurrentItem); Now General_DataGrid is a usercontrol that's just a datagrid. It's...
0
by: Frank 'Olorin' Rizzi | last post by:
Hello everyone. This is quite convoluted, but I'll try to make it simple. I have a couple of bottom-line questions (I guess): 1~ what happens between the Page_Load routine in the code behind...
1
by: Harold | last post by:
Hi all, having a little difficulty binding up a dropdownlist control in a datagrid column. I know I must be missing something Here are 2 methods. One is the DataGrid's ItemDataBound event to catch...
8
by: abcd | last post by:
I can get the value on the form at the server side by using Request.form("max") when max field is disabled I dont get value. For GUI and business logic purpose I have disabled some fields with...
47
by: Max | last post by:
Due to the behaviour of a particular COM object, I need to ensure that a request for a particular ASP page is finalized before another request for the page is processed. Does IIS have a way to...
2
by: deergregoryd | last post by:
I've got some PHP and javascript working together to create a marginless image popup from another arbitrary image. This works perfectly in Firefox, but IE bombs and I'm not really knowledgable...
7
by: =?Utf-8?B?QVRT?= | last post by:
HOWTO Make CStr for JavaScript on ASP w/ Request.Form and QueryString In ASP, Request.Form and Request.QueryString return objects that do not support "toString", or any JavaScript string...
6
by: John | last post by:
Hi I have a vs 2003 win form app which runs fine in IDE but once it is deployed via setup it bombs on start-up screen and wants to send MS the error report. This happens on multiple pc including...
5
by: Rory Becker | last post by:
I have had code in my Application_Start which is intended to run once at the start of my application's life. It loads connection information and similar from a known location. However I...
3
by: gee-dub | last post by:
Hi, I need to remove an object from a collection that has been enumerated with GetEnumerator similar to this... With lobjs.GetEnumerator .MoveNext() if Then lobjs.remove(.Current) end if...
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
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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.