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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:43:59+00:00 2026-06-12T23:43:59+00:00

I just create a new MVC 4 Web API project, and create a new

  • 0

I just create a new MVC 4 Web API project, and create a new .cshtml file, containing very simple HTML:

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
</head>
<body>
    <div>

    </div>
</body>
</html>

When opening the URL the following error displays:

Server Error in ‘/’ Application.

This type of page is not served.

Description: The type of page you have requested is not served because
it has been explicitly forbidden. The extension ‘.cshtml’ may be
incorrect. Please review the URL below and make sure that it is
spelled correctly.

Requested URL: /index.cshtml

I tested this scenario (exactly the same project) on a developing machine of one of my colleagues. It worked as expected. So I guess there must be something wrong with the configuration or some installation. But where to search? Neither local IIS nor Visual Studio Development Server works.

UPDATE

Accessing a .cshtml file directly isn’t for production code – it’s for training purposes, only!
Navigating to /Home/Index works perfectly fine. So there is nothing else, which is obviously wrong. Just accessing .cshtml files directly.

  • 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-12T23:44:00+00:00Added an answer on June 12, 2026 at 11:44 pm

    UPDATE 2:

    I have finally understood what you are trying to achieve. Sorry for me not understanding initially. I didn’t read your question carefully enough. You are trying to directly access a Razor page outside of the ~/Views folder.

    In ASP.NET MVC 4 this is disabled by default. In order to enable it all you have to do is adjust the following setting in your web.config:

    <add key="webpages:Enabled" value="true" />
    

    It’s value is false by default when you create a new ASP.NET MVC 4 project using any of the templates. So I guess your colleague already did this if you are saying that it works on his PC.


    ORIGINAL

    You should not request directly a .cshtml file in an ASP.NET MVC application. Those are views located in the ~/Views folder. They are not directly accessible. You need a corresponding controller action.

    For example let’s say that you have the following controller:

    public class HomeController: Controller
    {
        public ActionResult Index()
        {
            return View();
        }
    }
    

    and then have defined the ~/Views/Home/Index.cshtml view with the contents shown in your question.

    Now when you run your application you could navigate to /Home/Index which will execute the Index action of the Home controller and render the corresponding view.

    I would recommend you reading some getting started tutorials about ASP.NET MVC in order to familiarize yourself with the basic most fundamental concepts.


    UPDATE 1:

    The code that blocks requests to .cshtml files inside the ~/Views folder is situated inside the ~/Views/web.config file:

    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <handlers>
            <remove name="BlockViewHandler"/>
            <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
        </handlers>
    </system.webServer>
    

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

Sidebar

Related Questions

Very often, I just create a new folder and test things out in there.
This is just a simple question. I was trying to create a new object
I'm coming from web forms and still very new to MVC. I want to
Just a quick question, when you create a new controller for a new MVC
I have written a VERY simple MVC application which just displays a single string
I just create a new repo https://github.com/tolbard/ember-moving . In this repo I extend the
my co-worker has just create a new branch in the git repository which we
Just wondering if anyone has some good resources for learning how to create new
I'm new to shell,I just learned that use (command) will create a new subshell
I've just created anew schema & want to create a new table. When ever

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.