4

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" 

2 Answers 2

5

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>
3
  • 1
    Thank you, it seems to be working but on first try it still takes approx 3 seconds to load, even if it's completely empty, any tips ? I will accept answer regardless :) Jul 4, 2017 at 7:06
  • @Mathematics You are welcome and glad to hear it's working, Regarding the slowness issue, Do you face this behavior only in the first load? Is it similar to the previous behavior? could you please try to use fiddler to check the page performance and feedback us with the result. To be honest, I tried it on my side and it's working properly from the first try! Jul 4, 2017 at 10:31
  • Yes, first time is like 3 seconds then 1 seconds afterwords I would say, ok I will try using fiddle, thanks Jul 4, 2017 at 11:01
4

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.

4
  • +1. but sorry I am not able to follow your steps, could you please simplify them Jul 4, 2017 at 7:15
  • added simplification and solution image for your understanding. Jul 4, 2017 at 7:30
  • Thank you, so if I want to use minimal.master, all I have to do is download it and put in that folder ? :) do I need to create mycustom.html and mycustom.master too ? Jul 4, 2017 at 7:36
  • To use minimal.master, you just need to download it and put it in folder. No need to add mycustom.html & mycustom.master. Jul 4, 2017 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.