troubleshooting Question

Request.ServerVariables["HTTP_POST"] throws an exception

Avatar of ThomasCookScandinavia
ThomasCookScandinavia asked on
ASP.NETHTTP Protocol
4 Comments1 Solution1246 ViewsLast Modified:
Hi Guys,
I've come across an exception thats being recorded by my Log4Net database about once a second in my ASP.NET webapplication. The error generated is:

System.NullReferenceException: Object reference not set to an instance of an object.     at ASP.global_asax.Application_BeginRequest(Object sender, EventArgs e) in d:\inetpub\wwwroot\mywebsitename\Global.asax:line 37     at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

In my Global.asax file line 37 reads:
string[] hostParts = Request.ServerVariables["HTTP_HOST"].Split('.');

I use this bit of code to get the country domain extension of the url, and then set the UIculture to the correct language.

Isn't the HTTP_POST variable always set in the header of a web request?
ASKER CERTIFIED SOLUTION
davidmuto

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros