Modify Web Config and Global asax file of Sharepoint 2016 RRS feed

  • Question

  • Dear all,

    I meet some trouble with my WCF in sharepoint 2016.

    1. In WCF, I' using AutoMapper for mapping models. But I cannot initialize MapperProfile when ApplicationStart. How I can modify the Global.asax? I googled and found some solution, but they don't work.
    2. I need change MaxReceivedMessageSize for my service, but what I changed in web.config in solution not apply to server.

    Please help me, thanks a lot!

    Friday, April 5, 2019 9:21 AM

All replies

  • Please give me any solution
    Saturday, April 6, 2019 12:24 PM
  • Hi chanh,

    Try the following scripts:

    $contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService;
    $contentService.ClientRequestServiceSettings.MaxReceivedMessageSize = -1
    $wcfServiceSettings = New-Object Microsoft.SharePoint.Administration.SPWcfServiceSettings
    $wcfServiceSettings.ReaderQuotasMaxStringContentLength = 2147483647
    $wcfServiceSettings.ReaderQuotasMaxArrayLength = 2147483647
    $wcfServiceSettings.ReaderQuotasMaxBytesPerRead = 2147483647
    $wcfServiceSettings.MaxReceivedMessageSize = 2147483647
    $wcfServiceSettings.MaxBufferSize = 2147483647
    $wcfServiceSettings.ReaderQuotasMaxDepth = 2147483647
    $wcfServiceSettings.ReaderQuotasMaxNameTableCharCount = 2147483647
    $contentService.WcfServiceSettings["<!YOURWEBSERVICE IN LOWERCASE!>.svc"] = $wcfServiceSettings


    Best Regards,

    Michael Han

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, April 8, 2019 9:44 AM
  • Thanks Michael,

    But I don't know where I can apply this code. Because I think this code need to run when application initializing.

    And I can not modify Global.asax

    With the problem "Change MaxReceivedMessage", I override the MultipleBaseAddressWebServiceHostFactory and it's work.

    But I also need to know how I can modify Global.asax for AutoMapper & Ninject initialization.

    Thanks again, Michael.

    Monday, April 8, 2019 10:16 AM
  • Hi Chanh,

    Were you able to configure autoMapper in SharePoint WCF services?


    • Marked as answer by Chanh Tran Friday, January 17, 2020 7:37 AM
    • Unmarked as answer by Chanh Tran Friday, January 17, 2020 7:37 AM
    Friday, January 17, 2020 6:28 AM
  • Hi Kanishka_J,

    Yes, of course. I configured autoMapper like normal steps.

    But I don't know where I can call the init function. Because we can't modify the global.asax in Sharepoint 2016.

    To work around, I check and call the init function for autoMapper if need.


    Friday, January 17, 2020 7:46 AM