0
votes

I'm using SharePoint 2010, i created sites and subsites as anonymous access.

the anonymous users can access pages only, but if anonymous user play or change the URL from mysite:80/site1/Pages/default.aspx to

mysite:80/site1/Pages/ or /Pages , he will get login prompt.

my question: how can change this behavior, i mean when users change the URL, immediately redirect to home page or access denied page without login prompt (i prefer home page)???

1

1 Answers

0
votes

well in this case you have to add a http handler for your web application (register the module in web.config)

public void Init(HttpApplication context)
{
    context.PreRequestHandlerExecute += new EventHandler(PreRequestHandlerExecute);
}

public void Dispose()
{
}

/// <summary>
/// Pres the request handler execute.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
void PreRequestHandlerExecute(object sender, EventArgs e)
{    
    if(HttpContext.Current.Request.Path == "/_layouts/Authenticate.aspx")
    {
        HttpContext.Current.Response.Redirect(url.Replace("/_layouts/Authenticate.aspx", "/HOME_PAGE.aspx"));
    }
}