Get ClientContext from Full sharepoint url?

I am receiving a full sharepoint url like 'http://TestServer/sites/TestSite/TestSubSite/_vti_bin/lists.asmx'
I know the following code will not work as the url does not directly reference a site.
using (var context = new ClientContext(http://TestServer/sites/TestSite/TestSubSite/_vti_bin/lists.asmx))
My question is...considering urls are provided to me, what logic can I apply to modify the url so that I am only referencing the subsite 'http://TestServer/sites/TestSite/TestSubSite'?
Thanks heaps.

You can do it easily with string manipulation:
string url = "http://TestServer/sites/TestSite/TestSubSite/_vti_bin/lists.asmx";
int index = url.IndexOf("/_vti_bin");
if (index > 0)
string newurl = url.Substring(0, index);
Saifullah Shafiq
Blog:  
Twitter:   LinkedIn:
  Facebook:
  Google+:
  Latest Book:
A Practical Guide to SharePoint 2013

Similar Messages

  • Opening a document from a SharePoint URL

    Using the SDK's instructions on how to open a file, I cannot find the right way to open a file from a SharePoint URL
    I understand it relates to the ASFileSys, and I thought ASGetDefaultFileSysForPath would give me the right type, but I cannot figure the right combination of pathType to get the right ASFileSys.
    Whatever I try, I get the below error
    Code below:
    ASAtom pathType = ASAtomFromString("CString");
    ASText titleText = ASTextNew();
    ASTextSetPDText(titleText, "This PDF was opened by using the Acrobat SDK");
    ASFileSys fileSys = ASGetDefaultFileSysForPath(pathType, sharePointUrl);
    ASPathName pathName = ASFileSysCreatePathName(fileSys, pathType, sharePointUrl, NULL);
    AVDoc myDoc = AVDocOpenFromFile(pathName, fileSys, titleText);
    Anyone able to give me a push in the right direction?

    Are you able to open a sharepoint URL at all (i.e. with the UI, somehow)? If so, you may be able to write some test code in a plugin that looks up the code for the relevant ASFileSys. I have a feeling that ASGetDefaultFileSysForPath serves a very special and limited purpose.

  • Yosemite: How do I get back from full-screen to original window size?

    Okay, so today I used iPhoto for the first time since I reluctantly upgraded to Yosemite on Friday.
    iPhoto is one of the few apps I often take into full-screen mode, and so obviously I noticed today that they've kindly taken away the full-screen arrows in the top right-hand corner of the window in Yosemite.
    Posting a question about that in Support revealed the 'new improved' way to go full-screen, which is to click on the green traffic light in the top left-hand corner of the window.
    Fair enough, but how do I get my iPhoto window back to the size it was before I went full-screen? I tried clicking the green-button again, but that insists on the window being what I call 'maximised', ie. spread across the entire width of my desktop. I want to snap from full-screen back to the window size I had before going full screen.
    The arrows in the top right-hand corner used to do that perfectly well, but they're not there any more so I'm having to resort to laboriously re-sizing my window each time, which is far from ideal.
    Anyone able to advise me please?

    Do we know if it is iPhoto-specific, or do all app windows behave in this way?
    Actually, I suppose I could find that out for myself...

  • I cannot get back from full screen to normal view

    On full screen, there is no back button or any button other than the browsing tabs. I have to close firefox using task manager
    system is dell mini 10 using windows 7 starter.
    latest firefox, 3.6.10 downloaded today

    I got a way away from this problem. When in full screen, if you move you mouse to the top right corner of your screen, there would be the options "Close", "Restore" and "Minimize". You should click on restore and the screen would come back to the normal view. Thanks.
    regards,
    sunray005

  • How to get data from subsites list of SharePoint 2010 in ssrs

    Hi,
    Can someone help me on this issue.
    I want to create a report using ssrs, I have some of the data in SQL and some of the data in sharepoint list.
    First I need to go to SQL and get the data from the table which contains URL for the subsite in sharepoint.
    after that I need to go to all the subsites and go to perticulat list in the subsites and get data from that list.
    for example, their is a top level site "abc"
    it contains sub site "123", "456","567", etc.. All this sub sites contain a list by name "Sample List", Now I need to go to that sub site list(Sample List) and get list-item column say "created By" which
    is created on particular date. 
    in my report, I need to print the sub site "url/Title" which comes from SQL database and list-item column  "Created By" of that sub site list "Sample List".
    I tried using subreport inside a report by using "Microsoft SharePoint List" as a datasource, but when it comes to real time we don't know how many subsites will be created, so we can't create a datasource for each subsite site.
    I guess we need to be using XML as a datasource, but how can we go to particular subsite in query while using XML, since all subsites have list with the same name ?
    I appreciate your help.
    Thank you,
    Kishore 

    Hi Kishore,
    SQL Server Reporting Services(SSRS) supports expression-based connection strings. This will help us to achieve the goal you mentioned in this case:
    Create a new report
    Create a Data Source in the report with the connection string like this:
    http://server/_vti_bin/lists.asmx (We use static connection string instead of expression-based connection string now, as it is not supported to get fields based on expression-based connection string in design time. We will change it to be expression-based
    connection string later)
    Create the data set(as you have done using XML query language). Please use list name instead of GUID in the listName parameter.
    Design the report(e.g. Add controls to the report)
    Now, let's change the connection string to be expression-based. First, please add a parameter to the report, move this parameter to top. This parameter is used to store the sub site name.
    Open the Data Source editor, set the connection string to be: ="http://server/" & Parameters!parameterCreatedInStep5.value & "_vti_bin/lists.asmx"
    In the main report, pass the sub site name to the report we created above via the parameter created in step5
    That is all.
    Anyway, this is actually a SQL Server Reporting Service(SSRS) question. You can get better support on this question from:
    http://social.technet.microsoft.com/Forums/en/sqlreportingservices/threads
    For more information about Expression-Based connection string, please see:
    http://msdn.microsoft.com/en-us/library/ms156450.aspx#Expressions
    If there is anything unclear, please feel free to ask.
    Thanks,
    Jinchun Chen
    Jin Chen - MSFT

  • Search result to get data from bing search and display it in sharepoint page.

    I have configured result source which gets data from bing site,i have given following url as source url
    http://www.bing.com/search?q={?searchterms}&format=rss&Market=en-Us
    but it returns only 8 results from RSS. i want to get all results of search and display it in my SharePoint search results page. 
    any pointers will be helpful. 

    Hi,
    According to your post, my understanding is that you wanted to search result to get data from bing search and displayed it in sharepoint page.
    To display more items, you can modify the item number when you add
    New Query Rule.
    To get all results, I recommend to use the “Show More”
    link in the result page.
    You can enter the URL when you add New Query Rule:
    "More" link goes to the following URL: http://www.bing.com/search?q={searchterms}
    Here is a great blog for your reference:
    http://sharepoint-community.net/profiles/blogs/integrate-bing-with-sharepoint-online-2013-search
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Transaction Launcher : How to get return parameters from an external URL

    Hello,
    We need to launch an external URL in the Web Client UI. After the URL is launched, the user does some processing which results in some output values. These value have to be passed back to the Web Client UI and become a part of the quotation he is creating.
    We are able to launch the URL using the Transaction Launcher. But we are not able to find a way to get the output values from the external URL to the Web client UI.
    Please suggest any approach for this. It is OK even if we need to use an intermediate BSP to launch the external URL.
    Regards
    Ajay

    hi ajay
    I had a similar requirement , when the user clicks on button I want to launch the  External URL , can you please let me know how to launch the external url when the user cliks on button
    Thanks & Regards
    madhu

  • How to get argument value from portal desktop URL

    hi,guys
    I have a question ,it is how to get argument value.see:
    in one portal desktop,I have a hyperlink like this
    http://localhost:7001/TestPortal/appmanager/testPortal/testDST?eventId=1
    after click,then will be switch another desktop "testDST"
    I tried to get value from request,but failure.
    @RequestMapping
    public String listTestList(RenderRequest request, RenderResponse response,ModelMap model) {
    //HttpServletRequest httpRequest = (HttpServletRequest) ; //request.getAttribute("javax.portlet.portletc.httpServletRequest");
    //log.debug("httprequest eventId>>>" + httpRequest.getParameter("eventId"));
    log.debug("render request eventId>>>" + request.getParameter("eventId"));
    I can't get this value from request,also tried httpServeltRequest,but httpServletRequest can't get,it is null;
    so ,how to get this value,thank you very much.
    regards
    aris

    Hello,
    It is true for JSR168 portlets that you can't just arbitrarily set parameters on a URL and get access to them inside your portlet- you must use the appropriate APIs on the PortletURL class to set parameters that you can retrieve. This is the only portable (standards-compliant) way to implement the functionality you want.
    However, for your particular use-case, you can get the URL parameters from the (non-JSR168) HttpServletRequest object. The only reason you are getting a null object for that is because the attribute name is wrong. This should work:
    HttpServletRequest httpRequest = (HttpServletRequest)(request.getAttribute("javax.servlet.request"));
    String eventId = httpRequest.getParameter("eventId");
    Kevin

  • Am getting message from MacPro that my start up disc is full - but I can't find it and can't figure out what to do to help situation. I've been making a number of imovies, which generates junk files. help?

    I am getting message from MacPro that my start up disc is full - but I can't find this "start up disc" and can't figure out what to do to help situation. I've been making a number of imovies, which generates junk files and material that I should toss in the trash, but it is not clear to me  what items I can toss and which items I can't toss. Can you help? Using the imovie "help" support the system showed me under the menu item "go" where the "start up disc" should be - but that wasn't actually available on my menu!  Thanks for your help!

    Disk Utility 
    Get Info on the icon on Desktop
    Try to move this to the MacBook Pro forum
    Your boot drive should be 30% free to really perform properly. 10% minimum
    Backup, clone, use TimeMachine, use another drive for your projects and movies, replace and upgrade the internal drive even.

  • How do I get Adobe Acorbat to open a .pdf file from a sharepoint library without having to checkout the file

    I have a customer that is using Adobe Acrobat pro version 10.1. When they try and open a .pdf file from a SharePoint site, the user is prompted to check out and open the file or open the file. Is there a way to get Adobe Acrobat to open the .pdf file without prompting to check out or open?
    Thanks
    Jim

    This is mostly a lion thing, rather than a PSE thing. To disable applications opening where they left off last time for all the programs on your computer, go to system preferences>general and untick this box:
    You can also do on a per-program basis, but it's more complicated and the best thing to do is to search around for directions on the web and see which way is least uncomfortable for you.
    There's an odd little glitch in PSE that it opens the last image you had open, even if you closed it before quitting last time. Adobe says this is correct behavior, but of course it isn't.

  • Getting the local full path name of a file from an item File Browser

    Hi all,
    I would like to get the local full path name, of a file selected from an item 'File browser'.
    I see in wwv_flow_files the column 'name', but actually it's a kind of id like 'F1542335/myFile.gif' for example.
    What i want is the local path of this file ("C:\Documents and Settings\All Users\....\myFile.gif").
    I hope this is possible??
    Anyway, thanks all for reading.
    Ludo

    Hello, thank you for the answer.
    Please understand that I searched before posting, and not ony 15 min.
    What i mean is that the value of a File Browser in an Apex applocation is something like 'F1542335/myFile.gif', but what I need is the local path location.
    And 'F1542335/' is not the local path location, i can't use it. Or maybe there is a way to convert it in a proper path name, such as "C:\Documents and Settings\....", but I don't think so.
    So my question is : how to get the local path name of a file in Apex?
    I'll answer if I find some good things.
    Thanks
    Ludo
    Edited by: user12945874 on 06-avr.-2010 3:59

  • How to get videos from touch, in full resolution?

    How to get videos from touch, in full resolution?
    I tried email, but that compresses them.

    Import them as you would from any digital camera.
    http://manuals.info.apple.com/enUS/iPod_touch_iOS4.1_UserGuide.pdf

  • Get data from Sharepoint site in different farm using webservice, and current site using claims mode authentication.

    Hi , 
    I have a site that runs on   Claims Mode (  NTLM) . That site has a web part that needs to show the data from any  sharepoint farm, SharePoitn  2010 , or 2007 or 2003.
    I am getting 401 unauthorized when I   try to get data from webservice running in sharePoint context.
    But when I run the same code in  Windows Console application  then it is giving no error.
    What I doubt is that this issue is due to the reason that I have  set
    claims mode authentication.
    Because same code is running  in different farm in a site that is configured  using windows authentication.

    So generally speaking, you're talking about a VERY long running topic of authentication methods... and generally speaking, in the world of Windows, the only long running authentication options have been:
    - NTLM (limited to one hop)
    - Kerberos (unlimited hops)
    - Application level authentication (ex: SQL auth, also, no hops)
    Recently, Microsoft has been investing in Claims Based Auth... and I fully expect claims to start working their way into other systems (previously starting to work into Windows via the CardSpace technology, but also in other ways such as Win8's ability to
    log in with a LiveID)... but building a new authentication method into ALL applications is a VERY long process, and the complexity of claims adds a LOT of consideration (claims from the same AD can look VERY different depending on the STS, so lots of questions
    around things like bridging claims).
    So as far your SP auth needs...
    IF both applications are CLAIMS AWARE, then you MAY be able to use claims (which support unlimited hops)... but that's just not very likely yet (and will probably take another 5-10 years to be available across the entire enterprise)... otherwise, KERBEROS
    Outside of the Microsoft world... KERBEROS is open spec, so is supported by other systems (such as authenticating to linux)... claims based auth is also open spec, but again, still new... there are a few other options (LDAP, etc), but none that are native
    to Windows (so you rely on things like third party auth modules for Windows, which Novell has done for DECADES with NDS and eDir)
    And again, SharePoint can convert claims to Kerberos using the C2WTS... which MS uses internally for things Excel Services connecting to a backend SQL server... but it DOES require the Kerb and C2WTS configuration.
    if you're having issues using Kerb auth... then it sounds like Kerb isn't configured correctly... and Kerb is a PAIN to configure (whitepaper for SP Kerb is ~100 pages long)... IIS (and SharePoint) also has the added benefit of failing over to NTLM if Kerb
    fails (and you shouldn't disable this behavior, since it'll break other settings elsewhere)
    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com
    Strategic Data Systems - for all your SharePoint needs

  • SharePoint 2013: Infopath browser form "get form from" option greyed out

    In a web part page, I was able to add an app/list web part and an InfoPath web part, where the latter is setup with a "Get Form From" data connection with the former.
    Now I was trying to do the same within the edit page of the tasks list, as I was aiming to allow the user to edit the item related to the task and to approve the task from the same page. I can add the two web parts. However, the "Get Form From"
    data connection is not available in this case. What do I need to do to make it so?
    Thanks.

    Hi Ahmed,
    Please go to task list page and click customize form, then publish it in the InfoPath form designer.
    Now add a new page in SharePoint site, insert task list web part, then insert an InfoPath form web part. Click the triangle on the top right corner > Edit web part > Connections > Get form from, see if you could select task now.
    Regards,
    Rebecca Tu
    TechNet Community Support

  • Connect from Windows through screen sharing (VNC) and get out of full screen mode

    How do you get out of fullscreen mode?
    I connect to a OS X Lion computer through a Windows computer (which actually also is remote).
    I use TightVNC software on Windows to connect. It's the only VNC software I am able to connect to OS X Lion with. TightVNC is kind of weak otherwise in the way that it does not have features for OS X targets - like you can't send "command" key pushes, or even Ctrl pushes and other F2 etc keys just don't really work.
    Which means I cannot exit full screened apps by way of Command-F or similar. Moving the mouse cursor to the top of the screen also does not pop down the menu (although on some occasions I have been able to do this, I'm not sure how and it's terribly hard to reproduce).
    I'd need a on-screen way (like a button to click) to get out of full screen mode.
    Any ideas???

    Are you using TightVNC because you found it was the only VNC client that worked well with Mac OS X built-in VNC server?  Or is there another reason?
    Vine Server (aka OSXvnc - free to use the server)
    <http://www.macupdate.com/info.php/id/11283/vine-server-%26-viewer>
    plays nicer with 3rd party VNC clients, so that you could try any number of other WIndows VNC clients.  Maybe one of those will do a better job of sending Command/Control/Option keys.
    But if you do install Vine server make sure you turn off Mac OS X Screen Sharing (and/or Remote Managment) so that you do not conflict with port 5900.  Or via Vine Server configs, tell Vine Server to use a different port number, such as 5901, then make sure you connect to the correct port from your Windows client.

Maybe you are looking for

  • How do you play music in itunes from an external drive?

    if the library and itunes folder are on the external drive, how do you play the songs from there through a laptop? I have gotten that dreaded "original file not found" message over and over again. Thanks.

  • Initial load with LOBs

    Hi, i'm trying to do an inital load and I keep getting errors like these: ERROR OGG-01192 Oracle GoldenGate Capture for Oracle, ext1.prm: Trying to use RMTTASK on data types which may be written as LOB chunks (Table: 'TESTDB.BLOBTABLE'). ERROR OGG-01

  • Place a file in a random directory?

    Hello guys!  What i'm trying to do is to make an applescript that places a file in a random directory, anywhere on the computer. It would then make an alias for it in a set file, but I can handle that part. Can anyone explain how one would go about p

  • N8 having problem with e-mail that I can´t delete

    I sent an e-mail with a few pictures and I think it was too many pictures since it comes up that it can´t send the e-mail. I want to know how I can delete that e-mail and how to make my phone try to send it every time I am connected to internet. Also

  • IMac 27inch Resolution bug

    I have iMac 27inch and when i restarted, shut down or put my computer to sleep, when i turned it back on, the resolution is on 1280 x 720 and i can't change it back. I have os x mavericks 10.9.4 Im now stuck at that low resolution, my mac is old only