Domanda

I created an empty custom application page, it has all defaults and I didn't add anything to it.

It takes at least 3 minutes to load...

I don't need SharePoint functionality in this custom page but I do want code behind... one trick I can think of is removing SharePoint master page from it... as I don't need it all

It takes ages loading ribbon etc.. scripts which I don't want

If I change following,

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PerfDemo.aspx.cs" Inherits="my.ApplicationPages.Layouts.my.ApplicationPages.PerfDemo" 
    DynamicMasterPageFile="~masterurl/default.master" 
    %>

TO,

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PerfDemo.aspx.cs" Inherits="my.ApplicationPages.Layouts.my.ApplicationPages.PerfDemo" 
    MasterPageFile="~sitecollection/_catalogs/masterpage/masterpages/mycustom.master"
%>

It throws this error,

The file '/_layouts/15/mycustom.ApplicationPages/~sitecollection/_catalogs/masterpage/masterpages/mycustom.master' does not exist.

Also tried this but doesn't work

DynamicMasterPageFile="~masterurl/minimal.master" 
È stato utile?

Soluzione

To create a custom Application Page without using SharePoint Master Page. you should do the following:

  1. In <%@Page tag%>, Remove DynamicMasterPageFile="~masterurl/default.master" %> to looks like

     <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PerfDemo.aspx.cs" Inherits="my.ApplicationPages.Layouts.my.ApplicationPages.PerfDemo"%>
    
  2. Replace all Placeholders tags with normal <HTML>,<Head>,<Body>,<form id="form1" runat="server"> tags.

The application page should look like

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PerfDemo.aspx.cs" Inherits="my.ApplicationPages.Layouts.my.ApplicationPages.PerfDemo"%>

    <html>
    <head>
    </head>
    <body>
    <form id="form1" runat="server">
    <asp:Button ID="btn_Submit" runat="server" Text="M.Qassas" OnClick="Button1_Click" />
    </form>
    </body>
    </html>

Altri suggerimenti

There can be many reason for slow performance like search,limited hardware. But if you think its due to masterpage, you can resolve your issue by applying your custom or minimal masterpage.

To apply your custom masterpage, add your custom masterpage in "layouts/mycustom.ApplicationPages" folder (or say it should reside where your application page is) in your solution. Then try below code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PerfDemo.aspx.cs" Inherits="my.ApplicationPages.Layouts.my.ApplicationPages.PerfDemo" 
    MasterPageFile="mycustom.master"
%>

If you want to apply minimal.master, download it and put it in the "layouts/mycustom.ApplicationPages" folder (or say it should reside where your application page is) in your solution. Try below code:

<%@ Page CodeBehind="PerfDemo.aspx.cs" Inherits="my.ApplicationPages.Layouts.my.ApplicationPages.PerfDemo" MasterPageFile="minimal.master" Language="C#" %>

Your Solution should look like below when you add all files:

enter image description here

Now DynamicMasterPageFile="~masterurl/default.master", this code is default SharePoint code. When it is applied in application page, your page automatically uses site masterpage of your site collection.

Hope this will increase your performance.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top