Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8437617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:28:57+00:00 2026-06-10T07:28:57+00:00

I am trying to do this with an httpRequestBegin pipeline processor, but I don’t

  • 0

I am trying to do this with an httpRequestBegin pipeline processor, but I don’t seem to be able to access the user’s IP address from the given HttpRequestArgs parameter.

When I implement a class that has this method

public void Process(HttpRequestArgs args) {
    string ipAddress = args.Context.Request.UserHostAddress; // Not working
    string state = GetState(ipAddress); // already implemented elsewhere
    RedirectUserByState(state);  // already implemented elsewhere
}

I thought that this might hold the user’s IP address

args.Context.Request.UserHostAddress

but it causes this error instead (stack trace says it originates from the Process method):

System.Web.HttpException: Request is not available in this context

Any ideas? Thanks!

Edit, this is in Sitecore 6.1 and in the web.config at

<pipelines>
<!--...-->
    <httpRequestBegin>
        <!--...-->
        <processor type="Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel"/>
        <processor type="MySolution.Redirector, MySolution"/>
        <processor type="Sitecore.Pipelines.HttpRequest.LayoutResolver, Sitecore.Kernel"/>
        <!--...-->
    </httpRequestBegin>
    <!--...-->
</pipelines>

This server might be behind a load balancer.

Edit 2: It looks like I was trying to access both of these inside the Process() function and that is what was causing the error:

Sitecore.Context.Request
Sitecore.Context.Response
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:28:58+00:00Added an answer on June 10, 2026 at 7:28 am

    Where you defined your pipeline is fine. args.Context.Request should be available at this step in the request processing. The most likely cause is that this processor is being evoked under certain circumstances where the Context is not available. A simple check for the following should handle those cases:

    if (args.Context != null)
    {
        //....
    }
    

    The only other explanation I can think of is that GetState() or RedirectUserByState() are calling HttpContext.Current which is not available at this point (hence why Sitecore passes the context as an argument).

    Also, a load-balancer would not explain the exceptions, but you may have better luck checking for the following server variables if the IP ends up always be the same:

    args.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]
    args.Request.ServerVariables["REMOTE_ADDR"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying this, but it doesn't seem to work: users = User.find() This
I have been trying this for so long, but was not able to implement
Im trying this, but when i press it it dont changes, it only displays
I've been trying this from a long time. I'm having today's date and I
I'm trying this: SELECT FacilityID, FacilityName, CMSProviderID, [Provider Number] FROM G2_Facility, SCIPHospitalCompare WHERE [Provider
I'm trying this pattern: (r'^jobs/(?P<job_id>\d+)/$', job_handler) To work with jobs/ and jobs/{job_id}, but the
I am trying this code but i want to know what is the number
I am trying this code on UIScrollView but it's not working. The NSLog is
I was trying this script from a pdf file.I got stuck where the target
I have been trying this for some time but could not figure out yet.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.