Click here to Skip to main content
15,885,116 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionAccess Dynamic Controls Pin
tadhg883-Jul-06 5:35
tadhg883-Jul-06 5:35 
Questionproblem When Refreshing a page Pin
meetbinu20033-Jul-06 4:52
meetbinu20033-Jul-06 4:52 
AnswerRe: problem When Refreshing a page Pin
cloudking119663-Jul-06 23:36
cloudking119663-Jul-06 23:36 
Questionweb.sitemap and Page Title Pin
MaWeRic3-Jul-06 2:35
MaWeRic3-Jul-06 2:35 
AnswerRe: web.sitemap and Page Title Pin
Jesse Squire3-Jul-06 3:12
Jesse Squire3-Jul-06 3:12 
GeneralRe: web.sitemap and Page Title [modified] Pin
MaWeRic3-Jul-06 6:00
MaWeRic3-Jul-06 6:00 
QuestionProtect PDF Pin
Tech4U3-Jul-06 2:35
Tech4U3-Jul-06 2:35 
AnswerRe: Protect PDF Pin
Tech4U3-Jul-06 2:37
Tech4U3-Jul-06 2:37 
You may want to consider creating an HTTP handler for the PDF requests.

Instead of linking directly to the PDF, you would link to your HTTP handler, passing a document identifier in the query string. The handler would be responsible for handling user security and retrieving the PDF on the user's behalf. Sending the PDF via an HTTP handler would look something like:

using System;

using System.Web;



namespace Example

{

public class PDFServer : IHttpHandler

{

///

/// Signals whether the instance of the HttpHandler is reusable

/// accross requests.

///


///

/// <value>True if the instance is reusable, False otherwise

///

public bool IsReusable

{

get

{

return true;

}

} // End property IsReusable





///

/// Performs the needed processing and rendering for an Http Request.

///


///

/// <param name="context" />The Http contect for the request

///

public void ProcessRequest(HttpContext context)

{

// Grab the document id from the query string and use it to determine

// the document name and the path.



string docId = context.Request.Params["docId"];

string docName = DetermineDocumentName(docId);

string path = DetermineDocumentPath(docId);



// Set the response header to suggest a default file name.



context.Response.AppendHeader(String.Format("content-disposition","attachment; filename={0}", docName));



// Set the appropriate MIME type for a PDF file.



context.Response.ContentType = "application/pdf";



// Read the file directly to the response stream, then end the response.



context.Response.WriteFile(path);

context.Response.End();



} // End method ProcessRequest



} // End class PDFServer

} // End namespace Example





You can find plenty of information on creating HTTP handlers on the web. I'd
recommend looking at:

  • Microsoft's How To Create an ASP.NET HTTP Handler by Using Visual C# .NET,
    here[^]

  • Michael Flanakin's blog entry[^] on the topic

Hope that helps.


--Jesse

GeneralRe: Protect PDF Pin
Tech4U3-Jul-06 2:38
Tech4U3-Jul-06 2:38 
QuestionView State Pin
Minuab3-Jul-06 2:32
Minuab3-Jul-06 2:32 
AnswerRe: View State Pin
ritu43213-Jul-06 3:20
ritu43213-Jul-06 3:20 
AnswerRe: View State Pin
Jesse Squire3-Jul-06 3:28
Jesse Squire3-Jul-06 3:28 
QuestionDatagrid Problem Pin
Minuab3-Jul-06 1:32
Minuab3-Jul-06 1:32 
AnswerRe: Datagrid Problem Pin
amaneet3-Jul-06 1:40
amaneet3-Jul-06 1:40 
GeneralRe: Datagrid Problem Pin
Minuab3-Jul-06 1:53
Minuab3-Jul-06 1:53 
GeneralRe: Datagrid Problem Pin
murali.vemula3-Jul-06 2:10
murali.vemula3-Jul-06 2:10 
AnswerRe: Datagrid Problem Pin
Sushant Duggal3-Jul-06 1:52
Sushant Duggal3-Jul-06 1:52 
GeneralRe: Datagrid Problem Pin
Minuab3-Jul-06 2:04
Minuab3-Jul-06 2:04 
Questionmail sending problem Pin
amaneet3-Jul-06 1:20
amaneet3-Jul-06 1:20 
AnswerRe: mail sending problem Pin
Sushant Duggal3-Jul-06 1:43
Sushant Duggal3-Jul-06 1:43 
QuestionEditor like present in Microsoft Outlook.. Pin
Sushant Duggal3-Jul-06 1:18
Sushant Duggal3-Jul-06 1:18 
AnswerRe: Editor like present in Microsoft Outlook.. Pin
Jesse Squire3-Jul-06 3:44
Jesse Squire3-Jul-06 3:44 
QuestionSend a ASP.NET(1.x) mail with embedded images Pin
Sudhakar Pasupunuri3-Jul-06 0:38
Sudhakar Pasupunuri3-Jul-06 0:38 
AnswerRe: Send a ASP.NET(1.x) mail with embedded images Pin
Jesse Squire3-Jul-06 3:47
Jesse Squire3-Jul-06 3:47 
QuestionTo personalise the web page Pin
Sajitha K3-Jul-06 0:30
Sajitha K3-Jul-06 0:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.