Pages

Showing posts with label BUG in SharePoint 2013. Show all posts
Showing posts with label BUG in SharePoint 2013. Show all posts

Monday, June 2, 2014

Bug in SharePoint 2013 for Public Facing Sites - Popup message to Run ActiveX Controls

Recently in one of my SharePoint 2013 project which is Public Facing Site faced an issue of "The Web site wants to run the following add-on: 'Name ActiveX Control".


The SharePoint plugin that those web sites try to load is only useful for collaboration but not for public facing web sites.



Issue in Default SharePoint Javascript Files:-
The actual code will look like this in init.js file, which can be found inTemplates\Layouts\15\1033


function ProcessImn() {
if (EnsureIMNControl() && IMNControlObj.PresenceEnabled) { imnElems=document.getElementsByName("imnmark"); imnElemsCount=imnElems.length; ProcessImnMarkers(); }
}

function ProcessImnMarkers() {
for (i=0;i<imnMarkerBatchSize;++i) { if (imnCount==imnElemsCount) return; IMNRC(imnElems[imnCount].sip,imnElems[imnCount]); imnCount++; } setTimeout("ProcessImnMarkers()",imnMarkerBatchDelay);
}

Work Around Solution:-
Two ways you can go, one is

Comment all the above lines.Search for the function ProcessDefaultOnLoad() in the init.js file. Comment the ProcessImn() function. Now execute. Warning will no more display.


The other way and Preferred method will be,
Add below two Javascript Lines in your master Page,


function ProcessImn() {}
function ProcessImnMarkers() {}


Now for end user will not popup the The Web site wants to run the following add-on: 'Name ActiveX Control"





for more info:- http://support.microsoft.com/kb/931509

Friday, May 9, 2014

Configure Custom Access Denied Page - BUG in SharePoint 2013

There are many reasons that lead to the need to have your own Custom Access Denied Page, such as changing the text of the message or adding a more dynamic page / form to collect information from the user or perform some other function. Once you build your page and get it deployed to Layouts Folder and use below Powershell Commands


We can use the following PowerShell command for it

$web = Get-SPWebApplication http://WebApplicationURL/
Set-SPCustomLayoutsPage -Identity AccessDenied –RelativePath "/_layouts/15/Folder/CustomAccessDeniedPage.html" -WebApplication $web

Or

$web = Get-SPWebApplication http://WebApplicationURL/
$web.UpdateMappedPage([Microsoft.SharePoint.Administration.SPWebApplication+SPCustomPage]::AccessDenied, "/_layouts/15/Folder/CustomAccessDeniedPage.html ")
$web.Update()

Check the set property with below PowerShell command

$web = Get-SPWebApplication http://WebApplicationURL/
Get-SPCustomLayoutsPage -Identity AccessDenied -WebApplication $web | Format-List

You will observe the updated Value but when you try browsing you will get the default AccessDenied Page but not the custom access denied page. This is a known bug in SharePoint 2013 product. Till now with the current release of CU1 in Feb 2014, this issue is not been fixed.


Inorder to accomplish this, you can go with HttpHandler or HttpModule. Here we preferred to go with HttpModule and below is the code snippet for it.


public class CustomAccessDenied : IHttpModule
{
public void Init(HttpApplication app)
{
app.PreRequestHandlerExecute += new EventHandler(app_PreRequestHandlerExecute);
}
void app_PreRequestHandlerExecute(object sender, EventArgs e)
{
HttpContext context = HttpContext.Current;
string str = Path.GetFileName(new Uri(context.Request.Url.AbsoluteUri).LocalPath);

if (str.ToLower().Equals("accessdenied.aspx"))
{
context.Response.Redirect("/_layouts/15/customaccessdenied.aspx",true);
}
}

public void Dispose()
{
}
}


Note:- The custom access denied page [aspx] should has to Inherit from "Microsoft.SharePoint.ApplicationPages.AccessDeniedPage" class.
e.g. <%@PageLanguage="C#"Inherits="Microsoft.SharePoint.ApplicationPages.AccessDeniedPage"MasterPageFile="~/_layouts/simple.master"%>

Now write your c# code inline in PlaceHolderMain in the .aspx page. (This is the drawback).