Click here to Skip to main content
16,014,882 members
Home / Discussions / C#
   

C#

 
GeneralRe: A little help Pin
grewin19-Jun-08 19:08
grewin19-Jun-08 19:08 
QuestionsoRry for that wrong question.. Pin
maRk_maGic19-Jun-08 15:03
maRk_maGic19-Jun-08 15:03 
AnswerRe: soRry for that wrong question.. Pin
Ravi Bhavnani19-Jun-08 15:25
professionalRavi Bhavnani19-Jun-08 15:25 
Questionupdate an xml attribute Pin
nyjcr19-Jun-08 14:59
nyjcr19-Jun-08 14:59 
AnswerRe: update an xml attribute Pin
PIEBALDconsult19-Jun-08 15:08
mvePIEBALDconsult19-Jun-08 15:08 
GeneralRe: update an xml attribute Pin
nyjcr19-Jun-08 17:18
nyjcr19-Jun-08 17:18 
GeneralRe: update an xml attribute Pin
N a v a n e e t h19-Jun-08 21:14
N a v a n e e t h19-Jun-08 21:14 
QuestionHow2 Check if Request object is not null? Pin
mullermx19-Jun-08 14:41
mullermx19-Jun-08 14:41 
Hello everyone, I'm new here, so I'll be making very dumb questions...but in a couple of months I will definitely be answering questions xD.

I have an issue with some code, but i don't know how to:
a) verify that the Request object is not null
b) then make sure that the length of the ServerVariables collection is greater than zero

I got the following error:
Exception information:
    Exception type: NullReferenceException
    Exception message: Object reference not set to an instance of an object.
 
Request information:
    Request URL: http://x.x.x.x/Default.aspx
    Request path: /Default.aspx
    User host address: x.x.x.x
    User: 
    Is authenticated: False
    Authentication Type: 
    Thread account name: x\aspsqlhost
 
Thread information:
    Thread ID: 4
    Thread account name: x\aspsqlhost
    Is impersonating: False
    Stack trace:    at _Default.Page_Load(Object sender, EventArgs e) in x:\x\x\x\Default.aspx.cs:line 40


And they recommend me this:
You could verify that the Request object is not null, then make sure that the length of the ServerVariables collection is greater than zero before trying to access a specific element of the collection.

here's the code:

if (!User.Identity.IsAuthenticated)<br />
   {<br />
     if (Request.ServerVariables["HTTPS"] == "on" //LINE 40<br />
         || (Request.ServerVariables["HTTP_HOST"].Contains("localhost")))<br />
         {<br />
                bla bla bla;<br />
         }<br />
   }

AnswerRe: How2 Check if Request object is not null? Pin
Spacix One19-Jun-08 16:39
Spacix One19-Jun-08 16:39 
GeneralRe: How2 Check if Request object is not null? Pin
mullermx20-Jun-08 6:05
mullermx20-Jun-08 6:05 
GeneralRe: How2 Check if Request object is not null? Pin
Spacix One20-Jun-08 9:15
Spacix One20-Jun-08 9:15 
QuestionHow To: network sniffing on Vista? Pin
Super Lloyd19-Jun-08 13:54
Super Lloyd19-Jun-08 13:54 
AnswerRe: How To: network sniffing on Vista? Pin
Mark Churchill19-Jun-08 18:22
Mark Churchill19-Jun-08 18:22 
GeneralRe: How To: network sniffing on Vista? Pin
Super Lloyd19-Jun-08 18:36
Super Lloyd19-Jun-08 18:36 
AnswerRe: How To: network sniffing on Vista? Pin
leppie20-Jun-08 0:41
leppie20-Jun-08 0:41 
GeneralRe: How To: network sniffing on Vista? Pin
Super Lloyd20-Jun-08 4:39
Super Lloyd20-Jun-08 4:39 
AnswerRe: How To: network sniffing on Vista? Pin
Spacix One20-Jun-08 2:50
Spacix One20-Jun-08 2:50 
QuestionPrint Pin
netJP12L19-Jun-08 11:04
netJP12L19-Jun-08 11:04 
Questionswitch statemeent. Am I missing someting Pin
TheFoZ19-Jun-08 10:59
TheFoZ19-Jun-08 10:59 
AnswerRe: switch statemeent. Am I missing someting Pin
Judah Gabriel Himango19-Jun-08 11:09
sponsorJudah Gabriel Himango19-Jun-08 11:09 
GeneralRe: switch statemeent. Am I missing someting Pin
TheFoZ19-Jun-08 11:18
TheFoZ19-Jun-08 11:18 
GeneralRe: switch statemeent. Am I missing someting Pin
Judah Gabriel Himango19-Jun-08 11:50
sponsorJudah Gabriel Himango19-Jun-08 11:50 
GeneralRe: switch statemeent. Am I missing someting Pin
TheFoZ19-Jun-08 12:45
TheFoZ19-Jun-08 12:45 
AnswerRe: switch statemeent. Am I missing someting Pin
Guffa19-Jun-08 13:24
Guffa19-Jun-08 13:24 
GeneralRe: switch statemeent. Am I missing someting Pin
TheFoZ19-Jun-08 13:49
TheFoZ19-Jun-08 13:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.