Sharepoint 2013 SPView does not bring all items and/or fields

i created a handler to bring me a view, so say i had this url for the view
"http://server/sub1/sub2/Lists/myList/myItems.aspx"

to i sent my view the server relative url
"/sub1/sub2/Lists/myList/myItems.aspx"

and used it to open a new SPSite and SPWeb and get the items, yet i just couldn't get all my items.
yet when i tried by using the SPContext.Site it worked.

i dont know why, but the context of how the SPSite was opened affects the view.

my final code looks like this
using (SPSite tempSite = new SPSite(serverUrl + serverRelativeViewUrl))
{
    using (SPWeb getUrlWeb = tempSite.OpenWeb())
    {
        spwebUrl = getUrlWeb.ServerRelativeUrl;
    }
}


using (SPWeb tempWeb = spContext.Site.OpenWeb(spwebUrl))
{
    string viewUrl = item.MethodValue;
    if (viewUrl.StartsWith("/") == false)
    {
        viewUrl = "/" + viewUrl;
    }
    SPView oView;
    try
    {        oView = tempWeb.GetViewFromUrl(viewUrl);
    }
    catch (Exception viewEX)
    {
        Log...
    }
    ...more code...
    

Comments

Popular posts from this blog

c# Service Play Sound with NAudio example by Moshe

JS/JQ simulate Enter event

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem