SharePoint on security settings, the code that runs C # or vb.net on a SharePoint page is disabled by default
So what is a SharePoint page, open Designer, create a new ASPX page, and write some simple HTML on the page.
Then use the browser to open, the normal browsing will not error.
But if you write the C # code on the page, you will get an error.
If you want to run C # code in a SharePoint page, you need to add a node to the web.config
Configuration–> sharepoint–> safemode–> pageparserpaths Add a
<pageparserpath virtualpath= "/*"
compilationmode= "Always" allowserversidescript= "true" Includesubfolders= "true"/>
1. VirtualPath is where you want to enable the code block, the path can be written as "/customer.aspx" This is the path to the site,
2. When the full page name is written, the Includesubfolders property can be written without writing.
3. Other than compilation This attribute is very good to understand
There are 3 properties in the compilation
Always Auto Never This indicates whether the code in the page is to be compiled.
Then restart IIS, and it will take effect.
Write C # on the page
<script runat= "Server" >
protected void Page_Load (object sender, EventArgs e)
{
Response.Write (" Hello SharePoint ");
}
</:script>