Skip to content

Instantly share code, notes, and snippets.

@sitefinitysteve
Created November 11, 2014 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sitefinitysteve/d2ace979338e4d59e1f2 to your computer and use it in GitHub Desktop.
Save sitefinitysteve/d2ace979338e4d59e1f2 to your computer and use it in GitHub Desktop.
Download.aspx Document Download
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Download.aspx.cs" Inherits="SitefinityWebApp.Download" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
var max_time = 5;
var cinterval;
function countdown_timer() {
// decrease timer
max_time--;
document.getElementById('countdown').innerHTML = max_time;
if (max_time == 0) {
clearInterval(cinterval);
window.location.replace(document.getElementById('downloadNow').getAttribute("href"));
}
}
// 1,000 means 1 second.
cinterval = setInterval('countdown_timer()', 1000);
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>Your download will start in <span id="countdown">5</span> seconds, <asp:HyperLink ID="downloadNow" runat="server" Text="Download Now" ClientIDMode="Static" /></p>
Click <a href="/">here</a> to return to the dashboard
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Sitefinity.Security.Claims;
namespace SitefinityWebApp
{
public partial class Download : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var context = HttpContext.Current;
//This page is to allow users to download a file from an anon state more effectivly
if(!ClaimsManager.GetCurrentIdentity().IsAuthenticated){
if(context.Request.QueryString["file"] != null){
var file = context.Request.QueryString["file"];
downloadNow.NavigateUrl = file;
}else{
context.Response.Redirect("~/");
}
}else{
context.Response.Redirect("~/");
}
}
}
}
@manokwari0005
Copy link

Selamat bekerja

@manokwari0005
Copy link

Disipilin adalah bahagian dari kehidupan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment