Server relative URLs must start with spweb.serverrelativeurl in SharePoint

In this SharePoint tutorial, I will explain how to resolve the error “Server relative urls must start with spweb.serverrelativeurl” that occurs while working with CSOM SharePoint.

Server relative URLs must start with spweb.serverrelativeurl

Recently, I was working with an ASP.NET web application using Visual Studio. There, I have added a Content Search Web Part using CSOM. To add this web part, you have to retrieve the Page URL. I was adding this page URL as [“/Pages/WebPartPageName.aspx”].

While running this CSOM code, an error occurred: “SharePoint Server relative URLs must start with SPWeb.ServerRelativeUrl.” The error message is shown in the screenshot below.

server relative urls must start with spweb.serverrelativeurl csom

The Solution to the above error is: You should pass the Server Relative URL as “/sites/SiteName/Pages/WebPartPageName.aspx.” Once you pass this type of server-relative URL Path and rerun the code, it will execute and provide the appropriate result.

This is how to fix the error: Server relative URLs must start with spweb.serverrelativeurl that comes while working with CSOM SharePoint.

You may also like:

Leave a Comment

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Live Webinar

Quiz App Using SharePoint Framework (SPFx)

Learn to built a complete Quiz Management solution that enables admins to create and manage quizzes, categories, questions, and settings with an easy automated setup process in SharePoint. It also includes an interactive quiz experience for users and a powerful dashboard to track participation, analyze results, and view detailed performance reports with charts and answer insights.

📅 2nd June 2026 – 10:00 AM EST | 7:30 PM IST

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App