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

  • Home
  • SEARCH
  • 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 8310621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:31:33+00:00 2026-06-08T19:31:33+00:00

I am having different values of HttpContext object in my global.asax Application_AuthenticateRequest method and

  • 0

I am having different values of HttpContext object in my global.asax Application_AuthenticateRequest method and on the Authorize attribute filterContext’s HttpContext and also the controller Context.

I have set the application to run Single Sign on. Here is my web.config:

<authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn" name="FormsAuth" timeout="2880000"  domain="domain.com" slidingExpiration="true" defaultUrl="~/home/index"/>
    </authentication>

Then on log in, after validating the user, the authentication cookie is set.

FormsAuthentication.SetAuthCookie(userName, true);

Here is the problem now, when the breakpoint is hit on global asax Application_AuthenticateRequest method, the Request.IsAuthenticated is true, but when it hit the Authorize attribute’s OnAuthorize method, its filterContext.HttpContext.Request.IsAuthenticated is false. The page will always be redirected to the log on page even though the user is valid.

Can someone explain why is this so? Or any blog forums explaining the internal working of httpcontext in asp.net mvc. It seems Core ASP.NET httpcontext and MVC httpcontext is having different value in this case.

  • 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-08T19:31:34+00:00Added an answer on June 8, 2026 at 7:31 pm

    I just made a test using MVC3 and in both cases the IsAuthenticated property returns true if the user was authenticated correctly:

    Code used:

    Global.asax

    protected void Application_AuthenticateRequest(object sender, EventArgs e)
    {
        this.Context.Trace.Warn("From global asax: " + this.Context.Request.IsAuthenticated.ToString());
    }
    

    Custom Authorization filter

    public class CustomAuthorization : AuthorizeAttribute
    {
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            HttpContext.Current.Trace.Warn("from attribute: " + filterContext.RequestContext.HttpContext.Request.IsAuthenticated.ToString());
            base.OnAuthorization(filterContext);
        }
    }
    

    I hope this helps you to find the problem

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have form with two buttons having same name but different values ,how to
I'm having some checkboxes, where all have different values but all numbers. I want
I'm having problems searching in multiple tables for different values. When I search for
I am having different outputs on regex matching 1) when using Rubular and 2)
I am trying to understand if having different number of columns for different rows
I am posting different notifications to the notification bar. All are having different id's
In our e-commerce application, we have different kinds of products having different kinds of
Im having 2 different languages in my rails app and would like to be
We are having the two different website running for different products (both sites have
Having to interact with several different email servers via IMAP (using javamail), I have

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.