[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.mobile

Request.ServerVariables["SERVER_NAME"]

Erik

11/20/2002 2:11:00 PM

In my MMIT project, the app is blowing up when I try to
Request.ServerVariables["SERVER_NAME"]. In ASP.NET I use the below code
into the Global.asax's Application_Start method. It determines if the app
is running on Localhost or a production server and sets an Application
variable which I use everywhere to determine things like which database to
connect to.

Any ideas on how I can get this information? Thanks.

-------------------------------
CODE SNIPPET
-------------------------------
string webServer = Request.ServerVariables["SERVER_NAME"].ToUpper();
if(webServer == "LOCALHOST"){
Application["IsProduction"] = false;
}else{
Application["IsProduction"] = true;
}






2 Answers

Mark Fitzpatrick

11/20/2002 3:48:00 PM

0

Give a shot at testing to see if for some reason
Request.ServerVariables["SERVER_NAME"] == null, that could at least help
pinpoint an error. You might also try using the ToString().ToUpper(), in
case for some reason it isn't treating the value as a string initially and
it blows up when trying to ToUpper() an object.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Erik" <eolson@ArtsAndCraftsFair.com> wrote in message
news:uq9#3bJkCHA.2848@tkmsftngp10...
> In my MMIT project, the app is blowing up when I try to
> Request.ServerVariables["SERVER_NAME"]. In ASP.NET I use the below code
> into the Global.asax's Application_Start method. It determines if the app
> is running on Localhost or a production server and sets an Application
> variable which I use everywhere to determine things like which database to
> connect to.
>
> Any ideas on how I can get this information? Thanks.
>
> -------------------------------
> CODE SNIPPET
> -------------------------------
> string webServer = Request.ServerVariables["SERVER_NAME"].ToUpper();
> if(webServer == "LOCALHOST"){
> Application["IsProduction"] = false;
> }else{
> Application["IsProduction"] = true;
> }
>
>
>
>
>
>


Erik

11/21/2002 1:37:00 AM

0

MMIT isn't like Request.ServerVariables at all. I tried what you suggested
and even...

NameValueCollection coll = Request.ServerVariables;

and continue to get the error "Request is not available in this context".
I'm using .NET1.1. Can you get a handle on the ServerVariables?



"Mark Fitzpatrick" <fitzpatrick@smarteronline.com> wrote in message
news:Ou6rbPKkCHA.2580@tkmsftngp12...
> Give a shot at testing to see if for some reason
> Request.ServerVariables["SERVER_NAME"] == null, that could at least help
> pinpoint an error. You might also try using the ToString().ToUpper(), in
> case for some reason it isn't treating the value as a string initially and
> it blows up when trying to ToUpper() an object.
>
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP - FrontPage
>
> "Erik" <eolson@ArtsAndCraftsFair.com> wrote in message
> news:uq9#3bJkCHA.2848@tkmsftngp10...
> > In my MMIT project, the app is blowing up when I try to
> > Request.ServerVariables["SERVER_NAME"]. In ASP.NET I use the below code
> > into the Global.asax's Application_Start method. It determines if the
app
> > is running on Localhost or a production server and sets an Application
> > variable which I use everywhere to determine things like which database
to
> > connect to.
> >
> > Any ideas on how I can get this information? Thanks.
> >
> > -------------------------------
> > CODE SNIPPET
> > -------------------------------
> > string webServer = Request.ServerVariables["SERVER_NAME"].ToUpper();
> > if(webServer == "LOCALHOST"){
> > Application["IsProduction"] = false;
> > }else{
> > Application["IsProduction"] = true;
> > }
> >
> >
> >
> >
> >
> >
>
>