%3CLINGO-SUB%20id%3D%22lingo-sub-1133125%22%20slang%3D%22en-US%22%3ERe%3A%20.NET%20update%20on%20Azure%20breaking%20SharePoint%20provider%20hosted%20app%20parts%20(add-ins)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1133125%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20didn't%20work%20for%20me%3B%20it%20just%20resulted%20in%20an%20error.%26nbsp%3B%20However%2C%20I%20managed%20to%20achieve%20the%20same%20thing%20by%20using%20a%20rewrite%20rule%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20%20%20%20%3CREWRITE%3E%0A%20%20%20%20%20%20%3COUTBOUNDRULES%3E%0A%20%20%20%20%20%20%20%20%3CRULE%20name%3D%22Add%20SameSite%22%20precondition%3D%22No%20SameSite%22%3E%0A%20%20%20%20%20%20%20%20%20%20%3CMATCH%20servervariable%3D%22RESPONSE_Set_Cookie%22%20pattern%3D%22.*%22%20negate%3D%22false%22%3E%3C%2FMATCH%3E%0A%20%20%20%20%20%20%20%20%20%20%3CACTION%20type%3D%22Rewrite%22%20value%3D%22%7BR%3A0%7D%3B%20SameSite%3Dnone%22%3E%3C%2FACTION%3E%0A%20%20%20%20%20%20%20%20%20%20%3CCONDITIONS%3E%0A%20%20%20%20%20%20%20%20%20%20%3C%2FCONDITIONS%3E%0A%20%20%20%20%20%20%20%20%3C%2FRULE%3E%0A%20%20%20%20%20%20%20%20%3CPRECONDITIONS%3E%0A%20%20%20%20%20%20%20%20%20%20%3CPRECONDITION%20name%3D%22No%20SameSite%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CADD%20input%3D%22%7BRESPONSE_Set_Cookie%7D%22%20pattern%3D%22.%22%3E%3C%2FADD%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CADD%20input%3D%22%7BRESPONSE_Set_Cookie%7D%22%20pattern%3D%22%3B%20SameSite%3Dnone%22%20negate%3D%22true%22%3E%3C%2FADD%3E%0A%20%20%20%20%20%20%20%20%20%20%3C%2FPRECONDITION%3E%0A%20%20%20%20%20%20%20%20%3C%2FPRECONDITIONS%3E%0A%20%20%20%20%20%20%3C%2FOUTBOUNDRULES%3E%0A%20%20%20%20%3C%2FREWRITE%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20goes%20in%26nbsp%3B%3CFONT%3Esystem.webServer%20in%20web.config.%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1137693%22%20slang%3D%22en-US%22%3ERe%3A%20.NET%20update%20on%20Azure%20breaking%20SharePoint%20provider%20hosted%20app%20parts%20(add-ins)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1137693%22%20slang%3D%22en-US%22%3E%3CP%3EURL%20re-write%20is%20a%20heavier%20way%20of%20doing%20the%20same%20thing%20the%20web.config%20setting%20does.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20give%20the%20error%2C%20we%20might%20be%20able%20to%20get%20it%20working%20with%20the%20more%20efficient%20solution.%3C%2FP%3E%0A%3CP%3EMake%20sure%20you%20have%20well%20formed%20XML%2C%20that%20will%20throw%20errors%20if%20it%20is%20off.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1138003%22%20slang%3D%22en-US%22%3ERe%3A%20.NET%20update%20on%20Azure%20breaking%20SharePoint%20provider%20hosted%20app%20parts%20(add-ins)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1138003%22%20slang%3D%22en-US%22%3E%3CP%3EWell%2C%20the%20intellisense%20hadn't%20recognised%20the%20attributes%20when%20adding%20them%20in%20Visual%20Studio%2C%20so%20when%20I%20deployed%2C%20tested%2C%20and%20got%20an%20error%2C%20I%20just%20thought%20the%20xml%20couldn't%20being%20parsed%2C%20and%20that%20perhaps%20these%20attributes%20were%20only%20valid%20on%20framework%204.7%20onwards%20(I'm%20targeting%204.6.1).%26nbsp%3B%20However%2C%20I%20played%20around%20with%20it%20a%20bit%20more%20yesterday%20and%20ended%20up%20putting%20just%20the%20sessionState%20line%20back%20in%20-%20and%20that%20was%20OK.%26nbsp%3B%20So%20I%20decided%20to%20check%20that%20it%20must%20just%20be%20the%20httpCookies%20line%2C%20added%20that%20back%20in%2C%20and...it%20still%20worked.%26nbsp%3B%20So%20I%20think%20perhaps%20what%20happened%20was%20that%20in%20copying%20and%20pasting%20the%20two%20lines%20together%20from%20this%20page%2C%20there%20were%20maybe%20some%20hidden%20characters%20introduced%20which%20resulted%20in%20malformed%20xml.%26nbsp%3B%20That's%20all%20I%20can%20think%20of%2C%20anyway.%20Thanks%20for%20responding%2C%20though%2C%20and%20hope%20this%20helps%20someone%20else.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1141363%22%20slang%3D%22en-US%22%3ERe%3A%20.NET%20update%20on%20Azure%20breaking%20SharePoint%20provider%20hosted%20app%20parts%20(add-ins)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1141363%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20NET%204.7.2%20and%20tried%20the%20fix%20in%20web.config%20file%20and%20got%20warning%20%22The%20'sameSite'%20attribute%20is%20not%20allowed.%22.%20Should%20I%20ignore%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20760px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F168162iB9854CDC15FA3AF3%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Temp2.png%22%20title%3D%22Temp2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1141536%22%20slang%3D%22en-US%22%3ERe%3A%20.NET%20update%20on%20Azure%20breaking%20SharePoint%20provider%20hosted%20app%20parts%20(add-ins)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1141536%22%20slang%3D%22en-US%22%3E%3CP%3EI%20think%20you%20might%20just%20need%20to%20validate%20against%20another%20schema%20(which%20is%20what%20I%20ended%20up%20doing).%26nbsp%3B%20With%20the%20web%20config%20open%2C%20go%20to%20the%20XML%20menu%20at%20the%20top%20and%20choose%20Schemas.%20There%20should%20be%20one%20in%20the%20list%20called%26nbsp%3B%3CFONT%3EDotNetConfig472.xsd.%26nbsp%3B%20Make%20sure%20the%20%22Use%22%20column%20is%20set%20to%20%22Use%20this%20schema%22.%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%3EYou%20also%20have%20the%20targetFramework%20for%20httpRuntime%20set%20to%204.5%20instead%20of%204.7.2.%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1142705%22%20slang%3D%22en-US%22%3ERe%3A%20.NET%20update%20on%20Azure%20breaking%20SharePoint%20provider%20hosted%20app%20parts%20(add-ins)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1142705%22%20slang%3D%22en-US%22%3E%3CP%3EI%20Can%20not%20find%20%22%3CSPAN%3EDotNetConfig472.xsd%3C%2FSPAN%3E%22.%20The%20only%20schema%20that%20I%20can%20see%20is%20%22%3CSPAN%3EDotNetConfig.xsd%3C%2FSPAN%3E%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F168284i0A457546DCDE318B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Temp2.png%22%20title%3D%22Temp2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1143039%22%20slang%3D%22en-US%22%3ERe%3A%20.NET%20update%20on%20Azure%20breaking%20SharePoint%20provider%20hosted%20app%20parts%20(add-ins)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1143039%22%20slang%3D%22en-US%22%3E%3CP%3EOh%20well%2C%20try%20ignoring%20the%20error%20and%20deploying%20anyway.%26nbsp%3B%20You%20could%20even%20edit%20the%20web%20config%20directly%20in%20Azure%20as%20suggested%20in%20this%20article.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1143057%22%20slang%3D%22en-US%22%3ERe%3A%20.NET%20update%20on%20Azure%20breaking%20SharePoint%20provider%20hosted%20app%20parts%20(add-ins)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1143057%22%20slang%3D%22en-US%22%3E%3CP%3EI%20tried%20with%20VS2019%20and%20it%20has%20the%20valid%20schema%20file%20but%20error%20is%20still%20there%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F168320i22BD87919D2C0E34%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Temp2.png%22%20title%3D%22Temp2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1144218%22%20slang%3D%22en-US%22%3ERe%3A%20.NET%20update%20on%20Azure%20breaking%20SharePoint%20provider%20hosted%20app%20parts%20(add-ins)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1144218%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22%22%3EThanks%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F280501%22%20target%3D%22_blank%22%3E%40stmaximon%3C%2FA%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1203970%22%20slang%3D%22en-US%22%3ERe%3A%20.NET%20update%20on%20Azure%20breaking%20SharePoint%20provider%20hosted%20app%20parts%20(add-ins)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1203970%22%20slang%3D%22en-US%22%3E%3CP%3ENote%20that%20the%20system.web%20configuration%20settings%20have%20no%20effect%20in%20.NET%20Core%2C%20and%20applications%20written%20on%20.NET%20Core%20will%20require%20a%20code%20change%20to%20the%20configuration%20to%20use%20CookieOptions.SameSite%20%3D%3D%20SameSiteMode.None%20in%20a%20cookie%20policy%2C%20or%20when%20setting%20the%20cookie%20authentication%20up.%20There%20is%20a%20bit%20here%20on%20using%20OWIN%20to%20code%20a%20solution%20that%20also%20will%20omit%20the%20SameSite%20property%20when%20dealing%20with%20certain%20browser%20agents%20that%20are%20not%20up%20to%20date%20on%20the%20standard%20yet%20(and%20may%20never%20be%20updated)-%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdevblogs.microsoft.com%2Faspnet%2Fupcoming-samesite-cookie-changes-in-asp-net-and-asp-net-core%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdevblogs.microsoft.com%2Faspnet%2Fupcoming-samesite-cookie-changes-in-asp-net-and-asp-net-core%2F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20URL%20re-write%20workaround%20I%20believe%20was%20nessecitated%20by%20the%20use%20of%20.NET%20Core%20on%20some%20apps%2C%20while%20apps%20that%20were%20built%20on%20.NET%20Framework%20worked%20with%20the%20cookie%20settings%20in%20the%20system.web%20config%20section.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1132149%22%20slang%3D%22en-US%22%3E.NET%20update%20on%20Azure%20breaking%20SharePoint%20provider%20hosted%20app%20parts%20(add-ins)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1132149%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23800000%3B%22%3EThis%20post%20is%20a%20contribution%20from%20Westley%20Hall%2C%20an%20engineer%20with%20the%20SharePoint%20Developer%20Support%20team%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20have%20a%20SharePoint%20provider%20hosted%20add-in%20running%20on%20Azure%20web%20services%2C%20and%20it%20stops%20working%20when%20hosted%20on%20a%20SharePoint%20page%20inside%20a%20app%20part%20(or%20client%20web%20part%2Fadd-in)%2C%20or%20an%20iframe%2C%20then%20likely%20you%20have%20hit%20this%20issue%20caused%20by%20a%20change%20in%20the%20default%20cookie%20property%20%3CSTRONG%3ESameSite%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3EAfter%20the%20last%20.NET%20update%20rollout%2C%20the%20%3CSTRONG%3ESameSite%3C%2FSTRONG%3E%20property%20value%20on%20the%20ASP.NET_SessionId%20cookie%20is%20set%20to%20%3CSTRONG%3ELax%3C%2FSTRONG%3E%26nbsp%3Bwhich%20prevents%20the%20cookie%20from%20being%20sent%20to%20an%20iframe%20if%20the%20domain%20of%20the%20iframe%20is%20different%20than%20the%20host%20page.%20In%20a%20SharePoint%20provider%20hosted%20web%20part%20add-in%2C%20it%20will%20always%20be%20in%20a%20different%20domain.%3C%2FP%3E%0A%3CP%3EHere%20is%20an%20example%20of%20that%20session%20cookie-%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ESet-Cookie%3A%20ASP.NET_SessionId%3Dxxxxxxxx%3B%20path%3D%2F%3B%20HttpOnly%3B%20SameSite%3DLax%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENormally%20the%20xxxxxxx%20would%20be%20a%20random%20identifier%20of%20the%20session.%3C%2FP%3E%0A%3CP%3EThis%20session%20usually%20is%20used%20in%20the%20ASP.NET%20application%20to%20maintain%20the%20authentication%2C%20so%20what%20ends%20up%20happening%20is%20that%20the%20frame%20tries%20to%20redirect%20back%20to%20authenticate%20on%20the%20second%20time%20there%20is%20a%20post%20or%20any%20ajax%20call%20to%20the%20same%20app%20instead%20of%20using%20the%20session.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESometimes%20it%20will%20throw%20a%20405%20Method%20Not%20Allowed%20error%20since%20ajax%20calls%20can%20trigger%20a%20CORS%20OPTIONS%20request%2C%20and%20that%20will%20be%20rejected%20by%20SharePoint.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20resolve%20this%2C%20set%20the%20defaults%20in%20the%20web.config%20as%20follows%20in%20the%20system.web%20section-%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSYSTEM.WEB%3E%3C%2FSYSTEM.WEB%3E%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CHTTPCOOKIES%20samesite%3D%22%26quot%3BNone%26quot%3B%22%20requiressl%3D%22%26quot%3Btrue%26quot%3B%2F%22%3E%3C%2FHTTPCOOKIES%3E%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%3CSESSIONSTATE%20cookiesamesite%3D%22%26quot%3BNone%26quot%3B%22%3E%3C%2FSESSIONSTATE%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhen%20%3CSTRONG%3ESameSite%3C%2FSTRONG%3E%20is%20set%20to%20%3CSTRONG%3ENone%3C%2FSTRONG%3E%26nbsp%3Bit%20doesn't%20force%20the%20requirement%20for%20the%20iframe%20and%20host%20to%20be%20in%20the%20same%20domain.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMore%20on%20the%20.NET%20update%20here-%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fupdates%2Fapp-service-samesite-cookie-update%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fazure.microsoft.com%2Fen-us%2Fupdates%2Fapp-service-samesite-cookie-update%2F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20how%20to%20update%20the%20%3CSTRONG%3EWeb.config%3C%2FSTRONG%3E%20file%20on%20the%20live%20instance%20of%20your%20Azure%20web%20app-%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%20style%3D%22margin-left%3A%20.375in%3B%20direction%3A%20ltr%3B%20unicode-bidi%3A%20embed%3B%20margin-top%3A%200in%3B%20margin-bottom%3A%200in%3B%20font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%20type%3D%221%22%3E%0A%3CLI%20style%3D%22margin-top%3A%200%3B%20margin-bottom%3A%200%3B%20vertical-align%3A%20middle%3B%22%20value%3D%221%22%3E%3CSPAN%3ENavigate%20to%20your%20web%20application%20settings%20in%20Azure%20portal.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22margin-top%3A%200%3B%20margin-bottom%3A%200%3B%20vertical-align%3A%20middle%3B%22%3E%3CSPAN%3EClick%20on%20Advanced%20Tools%20and%20click%20Go%20(in%20the%20red%20box).%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22clipboard_image_10.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F167615i870CABAF2FBD10DE%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22clipboard_image_10.png%22%20alt%3D%22clipboard_image_10.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20margin-left%3A%20.375in%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%20style%3D%22margin-left%3A%20.375in%3B%20direction%3A%20ltr%3B%20unicode-bidi%3A%20embed%3B%20margin-top%3A%200in%3B%20margin-bottom%3A%200in%3B%20font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%20type%3D%221%22%3E%0A%3CLI%20style%3D%22margin-top%3A%200%3B%20margin-bottom%3A%200%3B%20vertical-align%3A%20middle%3B%22%20value%3D%223%22%3E%3CSPAN%3EIn%20the%20Kudu%20screen%20click%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-size%3A%2011.0pt%3B%20font-weight%3A%20bold%3B%20font-style%3A%20normal%3B%22%3EDebug%20console%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%3E%20%26gt%3B%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20bold%3B%20font-style%3A%20normal%3B%22%3ECMD%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%3E%20(in%20the%20red%20box).%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_1%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22clipboard_image_9.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F167614iD60898A6CA4A1D9E%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22clipboard_image_9.png%22%20alt%3D%22clipboard_image_9.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%200in%200in%200.375in%3B%20padding-left%3A%2030px%3B%22%3EThis%20will%20bring%20you%20to%20the%20file%20view%20below-%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22clipboard_image_8.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F167613iBD8D55C3A25DA9AC%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22clipboard_image_8.png%22%20alt%3D%22clipboard_image_8.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%20style%3D%22margin-left%3A%20.375in%3B%20direction%3A%20ltr%3B%20unicode-bidi%3A%20embed%3B%20margin-top%3A%200in%3B%20margin-bottom%3A%200in%3B%20font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%20type%3D%221%22%3E%0A%3CLI%20style%3D%22margin-top%3A%200%3B%20margin-bottom%3A%200%3B%20vertical-align%3A%20middle%3B%22%20value%3D%224%22%3E%3CSPAN%20style%3D%22font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%3EType%20the%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20bold%3B%20font-style%3A%20normal%3B%22%3ECD%20site%5Cwwwroot%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%3E%20command%20(lower%20red%20box)%20to%20get%20the%20root%20directory%20of%20the%20web%20application%2C%20and%20press%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20bold%3B%20font-style%3A%20normal%3B%22%3EEnter%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%3E.%20The%20file%20list%20on%20the%20upper%20part%20of%20the%20page%20should%20refresh%20to%20show%20the%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20bold%3B%20font-style%3A%20normal%3B%22%3E%20Web.config%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%3E%20file%20(you%20may%20need%20to%20scroll%20to%20see%20it).%20Click%20the%20edit%20icon%20(the%20pencil%20in%20a%20red%20box)%20to%20edit%20the%20file.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_3%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22clipboard_image_12.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F167617i2A4A558DD0EFFF9E%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22clipboard_image_12.png%22%20alt%3D%22clipboard_image_12.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20margin-left%3A%20.375in%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%20style%3D%22margin-left%3A%20.375in%3B%20direction%3A%20ltr%3B%20unicode-bidi%3A%20embed%3B%20margin-top%3A%200in%3B%20margin-bottom%3A%200in%3B%20font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%20type%3D%221%22%3E%0A%3CLI%20style%3D%22margin-top%3A%200%3B%20margin-bottom%3A%200%3B%20vertical-align%3A%20middle%3B%22%20value%3D%225%22%3E%3CSPAN%20style%3D%22font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%3EAdd%20the%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20bold%3B%20font-style%3A%20normal%3B%22%3EhttpCookies%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%3E%20and%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20bold%3B%20font-style%3A%20normal%3B%22%3EsessionState%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%3E%20cookie%20settings%20selected%20below.%20If%20the%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20bold%3B%20font-style%3A%20normal%3B%22%3Esystem.web%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%3E%20section%20is%20missing%2C%20add%20it%20so%20that%20it%20looks%20like%20the%20sample%20below.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%20style%3D%22margin%3A%200in%3B%20margin-left%3A%20.375in%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22padding-left%3A%2060px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22clipboard_image_5.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F167612i5AE911CFF5DF5066%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22clipboard_image_5.png%22%20alt%3D%22clipboard_image_5.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_4%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3COL%20style%3D%22margin-left%3A%20.375in%3B%20direction%3A%20ltr%3B%20unicode-bidi%3A%20embed%3B%20margin-top%3A%200in%3B%20margin-bottom%3A%200in%3B%20font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%20type%3D%221%22%3E%0A%3CLI%20style%3D%22margin-top%3A%200%3B%20margin-bottom%3A%200%3B%20vertical-align%3A%20middle%3B%22%20value%3D%226%22%3E%3CSPAN%20style%3D%22font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%3EClick%20%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20bold%3B%20font-style%3A%20normal%3B%22%3ESave%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-weight%3A%20normal%3B%20font-style%3A%20normal%3B%22%3E.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%20style%3D%22margin-top%3A%200%3B%20margin-bottom%3A%200%3B%20vertical-align%3A%20middle%3B%22%3E%3CSPAN%3EConfirm%20that%20your%20add-in%20web%20parts%20are%20working%20as%20expected.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThis%20change%20should%20also%20be%20added%20to%20any%20source%20code%20projects%20that%20the%20web%20application%20was%20deployed%20from%2C%20for%20future%20deployments.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1132149%22%20slang%3D%22en-US%22%3E%3CP%3EAre%20your%20app%20parts%20not%20rendering%3F%3C%2FP%3E%0A%3CP%3EAre%20you%20seeing%20405%20Method%20Not%20Allowed%20errors%2C%20or%20CORS%20errors%3F%3C%2FP%3E%0A%3CP%3EIs%20your%20provider%20hosted%20app%2Fadd-in%20on%20Azure%20web%20services%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThen%20this%20article%20is%20for%20you...%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1132149%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

This post is a contribution from Westley Hall, an engineer with the SharePoint Developer Support team

 

If you have a SharePoint provider hosted add-in running on Azure web services, and it stops working when hosted on a SharePoint page inside a app part (or client web part/add-in), or an iframe, then likely you have hit this issue caused by a change in the default cookie property SameSite.

After the last .NET update rollout, the SameSite property value on the ASP.NET_SessionId cookie is set to Lax which prevents the cookie from being sent to an iframe if the domain of the iframe is different than the host page. In a SharePoint provider hosted web part add-in, it will always be in a different domain.

Here is an example of that session cookie-

Set-Cookie: ASP.NET_SessionId=xxxxxxxx; path=/; HttpOnly; SameSite=Lax

 

Normally the xxxxxxx would be a random identifier of the session.

This session usually is used in the ASP.NET application to maintain the authentication, so what ends up happening is that the frame tries to redirect back to authenticate on the second time there is a post or any ajax call to the same app instead of using the session.

 

Sometimes it will throw a 405 Method Not Allowed error since ajax calls can trigger a CORS OPTIONS request, and that will be rejected by SharePoint.

 

To resolve this, set the defaults in the web.config as follows in the system.web section-

 

<system.web>
    <httpCookies sameSite="None" requireSSL="true"/>
    <sessionState cookieSameSite="None" />

 

When SameSite is set to None it doesn't force the requirement for the iframe and host to be in the same domain.

 

More on the .NET update here-

https://azure.microsoft.com/en-us/updates/app-service-samesite-cookie-update/

 

Here is how to update the Web.config file on the live instance of your Azure web app-

 

  1. Navigate to your web application settings in Azure portal.
  2. Click on Advanced Tools and click Go (in the red box).
 

clipboard_image_10.png

 

  1. In the Kudu screen click Debug console > CMD (in the red box).
 

clipboard_image_9.png

This will bring you to the file view below-

 

clipboard_image_8.png

 

 

  1. Type the CD site\wwwroot command (lower red box) to get the root directory of the web application, and press Enter. The file list on the upper part of the page should refresh to show the Web.config file (you may need to scroll to see it). Click the edit icon (the pencil in a red box) to edit the file.

 

 

clipboard_image_12.png

 

  1. Add the httpCookies and sessionState cookie settings selected below. If the system.web section is missing, add it so that it looks like the sample below.

 

clipboard_image_5.png

 
  1. Click Save.
  2. Confirm that your add-in web parts are working as expected.

 

This change should also be added to any source code projects that the web application was deployed from, for future deployments.

10 Comments
Regular Visitor

This didn't work for me; it just resulted in an error.  However, I managed to achieve the same thing by using a rewrite rule:

 

    <rewrite>
      <outboundRules>
        <rule name="Add SameSite" preCondition="No SameSite">
          <match serverVariable="RESPONSE_Set_Cookie" pattern=".*" negate="false" />
          <action type="Rewrite" value="{R:0}; SameSite=none" />
          <conditions>
          </conditions>
        </rule>
        <preConditions>
          <preCondition name="No SameSite">
            <add input="{RESPONSE_Set_Cookie}" pattern="." />
            <add input="{RESPONSE_Set_Cookie}" pattern="; SameSite=none" negate="true" />
          </preCondition>
        </preConditions>
      </outboundRules>
    </rewrite>

 

This goes in system.webServer in web.config.

Microsoft

URL re-write is a heavier way of doing the same thing the web.config setting does. 

If you give the error, we might be able to get it working with the more efficient solution.

Make sure you have well formed XML, that will throw errors if it is off.

Regular Visitor

Well, the intellisense hadn't recognised the attributes when adding them in Visual Studio, so when I deployed, tested, and got an error, I just thought the xml couldn't being parsed, and that perhaps these attributes were only valid on framework 4.7 onwards (I'm targeting 4.6.1).  However, I played around with it a bit more yesterday and ended up putting just the sessionState line back in - and that was OK.  So I decided to check that it must just be the httpCookies line, added that back in, and...it still worked.  So I think perhaps what happened was that in copying and pasting the two lines together from this page, there were maybe some hidden characters introduced which resulted in malformed xml.  That's all I can think of, anyway. Thanks for responding, though, and hope this helps someone else.

New Contributor

I am using NET 4.7.2 and tried the fix in web.config file and got warning "The 'sameSite' attribute is not allowed.". Should I ignore this?

 

Temp2.png

Regular Visitor

I think you might just need to validate against another schema (which is what I ended up doing).  With the web config open, go to the XML menu at the top and choose Schemas. There should be one in the list called DotNetConfig472.xsd.  Make sure the "Use" column is set to "Use this schema". 

 

You also have the targetFramework for httpRuntime set to 4.5 instead of 4.7.2.

New Contributor

I Can not find "DotNetConfig472.xsd". The only schema that I can see is "DotNetConfig.xsd"

 

Temp2.png

Regular Visitor

Oh well, try ignoring the error and deploying anyway.  You could even edit the web config directly in Azure as suggested in this article.

New Contributor

I tried with VS2019 and it has the valid schema file but error is still there

 

Temp2.png

New Contributor

Thanks @stmaximon 

 

Microsoft

Note that the system.web configuration settings have no effect in .NET Core, and applications written on .NET Core will require a code change to the configuration to use CookieOptions.SameSite == SameSiteMode.None in a cookie policy, or when setting the cookie authentication up. There is a bit here on using OWIN to code a solution that also will omit the SameSite property when dealing with certain browser agents that are not up to date on the standard yet (and may never be updated)-

https://devblogs.microsoft.com/aspnet/upcoming-samesite-cookie-changes-in-asp-net-and-asp-net-core/

 

The URL re-write workaround I believe was nessecitated by the use of .NET Core on some apps, while apps that were built on .NET Framework worked with the cookie settings in the system.web config section.