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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:13:01+00:00 2026-06-13T14:13:01+00:00

I have implemented ASP.Net application deployed in IIS with http and https port enabled.

  • 0

I have implemented ASP.Net application deployed in IIS with http and https port enabled. Now i have an requirement to reject the HTTP requests basis on Web.Config value. If this value set to True then it should not accept requests which are coming with HTTP like it should throw an error Invalid Operation.. Try requesting with Secure connection. The first thing i did is to check this in Global.asax file as Below:

  if (Utilities.Utility.HttpsCheck)
    {
        if (!Request.IsSecureConnection)
        {
            Response.Write("Invalid Operation");
        }
    }

In this method i got an exception request is not available in this context. I googled it about this error and got to know that it can’t be possible to access Request in Global file in ASP.NET.

Next method I tried is to add this above code in every page of my project and checking this before going to process request. But by doing this way i can not have control of preventing request to HTML pages, i have some html pages also in my project these files also i need to restrict.

If I include code in Page wise then it is applying for that page only.. But i have some image/video files also in website these also needs to restrict.

Is there any better way out to do this? Please help me in this regard.

Thanks in Advance.

  • 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-13T14:13:02+00:00Added an answer on June 13, 2026 at 2:13 pm

    I have implemented the HTTP Module to restrict the HTTP access for my website basis on my config value. By using this I can be able to restrict the HTPP access to Image files and html pages also. Here is my Module Code:

    public void Init(HttpApplication context)
            {
                context.BeginRequest += new EventHandler(context_BeginRequest);
            }
    
            public void context_BeginRequest(Object source, EventArgs e)
            {
                //Code to reject the HTTP requests on basis of Config Value
                HttpApplication application = (HttpApplication)source;
                HttpContext context = application.Context;
    
                if (context != null)
                {
                    if (Utilities.Utility.HttpsCheck)
                    {
                        if (!context.Request.IsSecureConnection)
                        {
                            context.Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                            context.Response.StatusDescription = "Secure connetion required";
                            context.Response.End();
                        }
                    }
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented https on my application and now i'm trying to make IIS
I have deployed my ASP.NET web application on IIS (windows 2008 server). I have
we have implemented a web application in asp.net 4.0 and customer needs us to
I have implemented custom errors in my asp.net mvc application by following this article
I have developed an asp.net web application containing 40-50 pages. I have implemented logger
I have implemented a repository pattern in my asp.net mvc web application... But i
I have implemented URL mapping in our ASP.NET 4 application, but I have a
I have implemented SQL Server session mode for an asp.net application. <sessionState mode=SQLServer compressionEnabled=true
I have implemented ADFS authentication for an asp.net 4.0 application. I have hosted the
I am building an application in ASP.NET MVC 3 in which I have implemented

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.