• Url Properties of SPSite and SPWeb


    原文地址:::http://www.spdeveloper.co.in/tipsntricks/pages/values-for-spsite-spweb-url-properties.aspx

    There are some properties for SPSite and SPWeb class using which we can get the URL values for the sites and webs. The two most used of these properties are - 'ServerRelativeUrl' and 'Url'

    As a developer we use the values of the properties for writing some logic for satifying the business needs. Whenever I used to write a OM code to use these properties, the first question which flashes in my mind - "What values are returned by these properties?". I immediately create a cosole application, and check the values returned by these properties and contiue with the actual work. I have seen many other developers doing this. So, for a quick reference I prepared the below table which has the url values returned by these properties.

    Some poeple may find this easy, but some (like me ;)) get confused when the sites have managed paths. These properties return the managed path if the site has one. Here goes the list

    SCENARIO 1: A Site Collection (SPSite) without any managed path.

    URL : 'http://rams'
    PropertyValue
    SPSite.ServerRelativeUrl /
    SPSite.Url http://rams
    SPWeb.ServerRelativeUrl /
    SPWeb.Url http://rams
    Url - http://rams/about ('about' is a sub site)
    SPSite.ServerRelativeUrl /
    SPSite.Url http://rams
    SPWeb.ServerRelativeUrl /about
    SPWeb.Url http://rams/about

    This looks pretty simple. We get confused when sites are created using managed paths. Below are the samples values for site created with managed paths

    SCENARIO 2: A Site Collection with a managed path (of type Explict inclusion). For the below URL '/my' is the managed path

    URL : 'http://rams/my'
    PropertyValue
    SPSite.ServerRelativeUrl /my
    SPSite.Url http://rams/my
    SPWeb.ServerRelativeUrl /my
    SPWeb.Url http://rams/my
    Url - http://rams/my/about ('about' is a sub site)
    SPSite.ServerRelativeUrl /my
    SPSite.Url http://rams/my
    SPWeb.ServerRelativeUrl /my/about
    SPWeb.Url http://rams/my/about

    SCENARIO 3: A Site Collection with a managed path (of type Wilcard inclusion). For the below URL '/sites' is the managed path, and a site collection is created at '/blog'

    URL : 'http://rams/sites/blog'
    PropertyValue
    SPSite.ServerRelativeUrl /sites/blog
    SPSite.Url http://rams/sites/blog
    SPWeb.ServerRelativeUrl /sites/blog
    SPWeb.Url http://rams/sites/blog
    Url - http://rams/sites/blog/about ('about' is a sub site)
    SPSite.ServerRelativeUrl /sites/blog
    SPSite.Url http://rams/sites/blog
    SPWeb.ServerRelativeUrl /sites/blog/about

    SPWeb.Url

    http://rams/sites/blog/about

  • 相关阅读:
    虚函数/纯虚函数/抽象类/接口/虚基类
    泛型编程
    C++解题报告 : 迭代加深搜索之 ZOJ 1937 Addition Chains
    C++题解:Matrix Power Series ——矩阵套矩阵的矩阵加速
    C++矩阵加速经典题目:Warcraft III 守望者的烦恼 [vijos 1067]
    C++数论板题(弹药科技):Lengendre定理和欧拉函数
    Java并发工具包提供了哪些并发工具类
    Mac OS X系统深入了解--系统文件结构篇(二)
    Mac OS X系统深入了解--系统文件结构篇(一)
    Java Web(一) Servlet详解!!
  • 原文地址:https://www.cnblogs.com/fcq121/p/2773611.html
Copyright © 2020-2023  润新知