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 142789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:59:32+00:00 2026-05-11T07:59:32+00:00

HttpContext context = ((HttpApplication)sender).Context; In the above example, why do we cast sender to

  • 0

HttpContext context = ((HttpApplication)sender).Context;

In the above example, why do we cast sender to a HTTPApplication and not HTTPContext?

Also, what is the purpose of the brackets? I know they are for casting, but if you get rid of HTTPApplication and the surrounding brackets, that leaves:

(sender).Context; 

Why not sender.Context? Or generically, why the use of brackets anyway? I vaguely remember it is a way of casting but can’t remember specifics.

Secondly:

 string url = context.Request['url'];  int cacheDuration = Convert.ToInt32(context.Request['cache'] ?? '0');  string contentType = context.Request['type']; 

EDIT: I realised that you can write:

collection['key'] = 'value'; 

This is for a key-based collection and you store value where there is a key called ‘key’. So am I right in thinking you get the url where the key is ‘url’?

I know this is using HTTPContext, but in the indexer, what is ‘url’ meant to mean? It is just a string saying url, not even a real url. Likewise for ‘cache’ and ‘type’. If one writes ‘type’, as in the last line of code, does that get back the type (HTTP/HTTPS) used?

Thanks

  • 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. 2026-05-11T07:59:33+00:00Added an answer on May 11, 2026 at 7:59 am

    It needs to cast sender to HttpApplication because (presumably) that’s the actual type – it then gets an HttpContext via the HttpApplication.Context property.

    Given that, you do need the cast, therefore the bracketing is reasonable.

    For the second part: 'url', 'cache' and 'type' are just the names of request parameters (which are documented to come from the cookies, form submission, server variables or URL query parameters). So the original URL might be:

    http://server.com/Foo.aspx?url=someurl&cache=10&type=text/plain

    … or the values could come from cookies etc. I would hope that given that information, it would be clear where they’d really come from in this case 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 227k
  • Answers 227k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I don't know the implementation, but if your nodes have… May 13, 2026 at 1:28 am
  • Editorial Team
    Editorial Team added an answer Try dojo.publish and dojo.subscribe Perhaps this is a better link May 13, 2026 at 1:28 am
  • Editorial Team
    Editorial Team added an answer I find the Rubber Duck Debugging strategy works well, too. May 13, 2026 at 1:28 am

Related Questions

I've been given the thrilling task of re-writing our exception handling system. Whilst I
I've created an HttpModule in ASP.NET to allow users to upload large files. I
When I try to rewrite a URL in ASP.NET I'm finding that the URL
I'm trying to build a proxy module for .NET, but I'm having trouble copying

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.