We help IT Professionals succeed at work.
Get Started

Request.ServerVariables["HTTP_POST"] throws an exception

Last Modified: 2012-05-05
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?
Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE