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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:27:42+00:00 2026-06-05T07:27:42+00:00

I have a ASP.NET 4.0 web forms application (IIS 7) where I am using

  • 0

I have a ASP.NET 4.0 web forms application (IIS 7) where I am using URL routing to allow friendly URLs. For example, instead of Blog.aspx?title=the-blog-title, I allow Blog/the-blog-title.

My question is: How do I prevent users from directly accessing Blog.aspx? I have included the following setting in my web.config:

<httpHandlers>
  <add verb="*" path="*.aspx" type="System.Web.HttpForbiddenHandler" />
</httpHandlers>

This works, but it shows a ‘This type of page is not served’ error. Is it possible to simply display a 404 error for all .aspx page requests using IIS or web.config? (I know how to do this programatically, but I would prefer to use a config file if possible.)

  • 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-05T07:27:44+00:00Added an answer on June 5, 2026 at 7:27 am

    Use URL Rewriting to change the offending addresses to those you prefer. Here’s an article explaining the difference between the two ideas.

    SEO aspects of URL Rewriting

    URL Rewriting does not dilute SEO; in fact, that is how you establish canonical URLs, by rewriting the URL. Search engines only see the rewritten URL, not the URL used for the request.

    For example, if you have the following URLs that all point to your homepage:

    • http://example.com/
    • http://example.com/default.aspx
    • http://www.example.com/
    • http://www.example.com/default.aspx

    Then, you can rewrite the URL so anyone requesting any of the above URLs will be given the URL http://www.example.com/. This URL is the only one that would be seen by search engines, regardless of how the page was initially accessed.

    How Rewriting Works

    When you request a URL, whether that is for example.com/blog.aspx or example.com/blog, the request is sent to the web server. There, the URL rewrite engine evaluates the URL in the request headers. If the URL matches any rewrite rules (for example, to remove the .aspx extension), then the web server issues a 301 Permanently Moved response code, with the new URL in the response header.

    After receiving the response, the browser requests the new URL. Search engine bots like googlebot see the permanent redirect code and changes the index of that link to the requested URL. So, if it has indexed example.com/blog.aspx, or anyone links to it, the 301 Permanently Moved response tells the spider that the new URL is actually example.com/blog. Therefore, in the eyes of the spider, example.com/blog.aspx is example.com/blog.

    This is how people move websites and pages around without losing PageRank, because the rewrite engine points the spiders to the new page, so the new page name keeps the same PageRank as the old page name.

    URL Rewriting is also how sites can be accessed using, to take this site as an example, www.stackoverflow.com and have the browser actually show stackoverflow.com (without the www). The rewrite engine tells the browser (and the spider) that references to www.stackflow.com are actually called stackoverflow.com.


    While you have already found a solution with which you are happy, I’d highly recommend spending some time looking at URL Rewriting, as it is a more elegant and professional solution than sending error messages. It’ll also allow you to redirect all non-www requests to the www url, further preventing dilution of your SEO ranking.

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

Sidebar

Related Questions

I have an ASP.NET 4 Web Forms app that is using URL Routing. I
I have a ASP.NET Web Forms application and I'm using some dynamic controls in
I have an ASP.NET web application that is using forms authentication. Everything is configured
I have installed an ASP.NET 4.0 Web forms application in IIS 7.5. If I
I have a C# web forms ASP.NET 4.0 web application that uses Routing for
I have a ASP.NET Web Forms application that internally makes many SOAP and REST
I have built a small web application in asp.net c# in VS 2010 using
I have an ASP.NET MVC 3 Beta application running on IIS. In my web.config
I have an ASP.Net 4.0 web forms application that is ignoring any changes I
I have an ASP.NET web application with a web forms projects with dependencies on

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.