programmatically customize browser.compact file in sharepoint2010 feature

Answered programmatically customize browser.compact file in sharepoint2010 feature

  • Wednesday, June 01, 2011 12:13 PM
     
     

    Hi,

    I want to customize the browser.compact file using feature. For adding web part for mobile I need to add dll entry in browser.compact file. To automate this process I want to customize the browser.compact file so that Once I activate my feature the entry should update into this file.

     

    Any idea or apporach?


    Regards Ravi http://sharepointwithravi.blogspot.com

All Replies

  • Wednesday, June 01, 2011 12:37 PM
     
     
    About the only way I can see to do this would be through a Feature Reciever.  The compat.browser file is stored in the App_Browsers directory of the web application.  From what I've seen its copied there when the Web Application is created from the Config\Browsers directory in the SharePoint root.  Changing the original file after the Web Application has been created won't have any effect.  But you could write a feature receiver to change the file programatically on feature activation.  But I don't think the changes will take effect until the next IISreset.
    Paul Stork SharePoint Server MVP
  • Wednesday, June 01, 2011 12:49 PM
     
     

    Thanks Paul for your reply,

    Through feature I dont have idea how to add entry in browser.compact file. I am still looking for idea how to edit this file?


    Regards Ravi http://sharepointwithravi.blogspot.com
  • Wednesday, June 01, 2011 2:02 PM
     
     

    Hi Ravi,

     

    You can use XmlTextReader and XmlTextWriter to update your browser.compact file, please follow the link below for full sample code. 

    http://support.microsoft.com/kb/307548

     


    Ashraf ul Islam
    Sharepoint Consultant
  • Wednesday, June 01, 2011 2:10 PM
     
     Answered

    You don't need to. You can add your own custom *browser.compat files to that folder and they will be processed too.

    For example ...

    ConstosoMobile_Browser.compat

    I would not recommend modifying the original files.


    regards
    Martin Hatch
    MCPD SharePoint 2010 | .Net Web Development
    MCTS WSS 3.0 | MOSS 2007
    Visit my Blog - www.martinhatch.com
    • Marked As Answer by Porter Wang Tuesday, June 07, 2011 11:52 AM
    •  
  • Thursday, June 02, 2011 3:02 AM
     
     

    Thanks Ashraf and Martin,

     

    But I am agree with Martin about creating new browser.compact file but I dont how to change the mapping from original browser.compact file to custombrowser.compact file.


    Regards Ravi http://sharepointwithravi.blogspot.com
  • Thursday, June 14, 2012 4:38 PM
     
     

    Can you override Values from the original browser.compat file in this way? I am trying to disable built in Mobile support like explained here. but when I change the compat.browser file I get an error for the entire site, even If I only add a backspace to this file it causes it to get the error.

    I am trying to over ride the <capability name="isMobileDevice" value="False" /> for all values in the file.


    Cheers, TMG