I have recently set up a website that uses cloudflare free ssl. When using ajax calls for pagination I get a mixed content error, I assume because it's still at some point transmitted over http!? I tried using the instructions for https redirect here: https://learn.microsoft.com/en-us/aspnet/core/security/enforcing-ssl but that just ended up in a loop, giving the too many redirects error.
This is the specific error relating to mixed content:
Mixed Content: The page at 'https://www.andysmobilearchery.co.uk/events/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://www.andysmobilearchery.co.uk/events/index/?page=2&x-requested-with=xmlhttprequest&=1502287619453'. This request has been blocked; the content must be served over HTTPS.
Is there a fix for this, or am I going to have to remove the ajax functions?
Any help is appreciated!
@if (Model.Pager.EndPage > 1)
{
<ul class="pagination">
@if (Model.Pager.CurrentPage > 1)
{
<li>
<a asp-controller="Events" asp-action="_Index" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#paged-content" asp-route-page="1" data-ajax-method="GET" asp-route-dfrom="@ViewBag.dfrom" asp-route-dto="@ViewBag.dto" asp-route-search="@ViewBag.search">First</a>
</li>
<li>
<a asp-controller="Events" asp-action="_Index" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#paged-content" data-ajax-method="GET" asp-route-page="@(Model.Pager.CurrentPage - 1)" asp-route-dfrom="@ViewBag.dfrom" asp-route-dto="@ViewBag.dto" asp-route-search="@ViewBag.search">Previous</a>
</li>
}
@for (var page = Model.Pager.StartPage; page <= Model.Pager.EndPage; page++)
{
<li class="@(page == Model.Pager.CurrentPage ? "active" : "")">
<a asp-controller="Events"asp-action="_Index" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#paged-content" data-ajax-method="GET" asp-route-page="@page" asp-route-dfrom="@ViewBag.dfrom" asp-route-dto="@ViewBag.dto" asp-route-search="@ViewBag.search">@page</a>
</li>}
@if (Model.Pager.CurrentPage < Model.Pager.TotalPages)
{
<li>
<a asp-controller="Events" asp-action="_Index" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#paged-content" data-ajax-method="GET" asp-route-page="@(Model.Pager.CurrentPage + 1)" asp-route-dfrom="@ViewBag.dfrom" asp-route-dto="@ViewBag.dto" asp-route-search="@ViewBag.search">Next</a>
</li>
<li>
<a asp-controller="Events" asp-action="_Index" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#paged-content" data-ajax-method="GET" asp-route-page="@(Model.Pager.TotalPages)" asp-route-dfrom="@ViewBag.dfrom" asp-route-dto="@ViewBag.dto" asp-route-search="@ViewBag.search">Last</a>
</li>
}
</ul>
}
I have now noticed that other sites where I have this implemented work just fine (3 others!), I am using asp.net boilerplate which adds a trailing slash to urls, if I disable this the events page works, but my reviews page stops... I am baffled lol