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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:05:25+00:00 2026-06-14T12:05:25+00:00

I am trying to use C# code in an aspx page within SharePoint 2010.

  • 0

I am trying to use C# code in an aspx page within SharePoint 2010. I keep getting the “Code blocks are not allowed” error.

My aspx page located at (server)/SitePages/ajax.aspx: (edited in SharePoint Designer 2010 if it matters)

<%@ Page Language="C#" %>
<script runat="server">
    Response.Write("Hello world");
</script>

I added the following to web.config at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG

<PageParserPath VirtualPath="/SitePages/ajax.aspx" CompilationMode="Always" AllowServerSideScript="true" />

Here is the same line that I added to web.config, shown in context:

<SharePoint>
  <SafeMode 
        MaxControls = "200"  
        CallStack = "false"
        DirectFileDependencies ="10"
        TotalFileDependencies = "50"
        AllowPageLevelTrace = "false"
        >
        <PageParserPaths>
            <PageParserPath VirtualPath="/SitePages/ajax.aspx" CompilationMode="Always" AllowServerSideScript="true" />
        </PageParserPaths>

Why do I still get the “Code blocks” error? Is there another security switch somewhere?

(I know custom web parts are the preferred solution, but I don’t think that will suffice here because the return value should be json – this is a page to hit via ajax to get data.)

  • 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-14T12:05:26+00:00Added an answer on June 14, 2026 at 12:05 pm

    I suppose, you have to define PageParserPath element in an Web application web.config that is located C:\inetpub\wwwroot\wss\VirtualDirectories[application folder]\web.config.

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

Sidebar

Related Questions

I'm trying to use the jQuery grid. I keep getting this error at the
We're trying to create a .NET aspx page that will have a PDF within
In my Default.aspx web page i use the following code in order to save
I am trying to use PostBackUrl in my default.aspx page to postback to my
I'm getting the following Error when trying to use OOP (for the first time),
I have been trying to use the Response.End() method and I keep on getting
I'm just trying to use aspx for the first time and I'm getting a
Trying to use this code to connect the AD PrincipalContext context = new PrincipalContext(ContextType.Domain,
I'm trying to use the code review feature when I check-in my files but
i am trying to use this code: <%= File.ReadAllText(Server.MapPath(Members/newsletters/welcome.html))%> which works great but now

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.