Created
November 11, 2014 13:27
-
-
Save sitefinitysteve/d2ace979338e4d59e1f2 to your computer and use it in GitHub Desktop.
Download.aspx Document Download
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("~/"); | |
} | |
} | |
} | |
} |
Disipilin adalah bahagian dari kehidupan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Selamat bekerja