Click here to Skip to main content
15,914,488 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Form -- Modal dialog -- Postback --- refresh form? Pin
minhpc_bk3-Jul-06 20:49
minhpc_bk3-Jul-06 20:49 
GeneralRe: Form -- Modal dialog -- Postback --- refresh form? Pin
devvvy3-Jul-06 21:35
devvvy3-Jul-06 21:35 
GeneralRe: Form -- Modal dialog -- Postback --- refresh form? Pin
minhpc_bk4-Jul-06 0:22
minhpc_bk4-Jul-06 0:22 
QuestionDraw backs in using SQL server 2000 Pin
Tiger4563-Jul-06 14:48
Tiger4563-Jul-06 14:48 
AnswerRe: Draw backs in using SQL server 2000 Pin
Igor Sukhov3-Jul-06 18:47
Igor Sukhov3-Jul-06 18:47 
QuestionData push from server to desktop applications Pin
mastjabs3-Jul-06 12:34
mastjabs3-Jul-06 12:34 
AnswerRe: Data push from server to desktop applications Pin
minhpc_bk3-Jul-06 20:37
minhpc_bk3-Jul-06 20:37 
GeneralRe: Data push from server to desktop applications Pin
mastjabs4-Jul-06 12:31
mastjabs4-Jul-06 12:31 
GeneralRe: Data push from server to desktop applications Pin
minhpc_bk4-Jul-06 16:13
minhpc_bk4-Jul-06 16:13 
GeneralRe: Data push from server to desktop applications Pin
mastjabs5-Jul-06 6:50
mastjabs5-Jul-06 6:50 
GeneralRe: Data push from server to desktop applications Pin
minhpc_bk5-Jul-06 20:15
minhpc_bk5-Jul-06 20:15 
Question.mdf file or sql server to .sql script Pin
emran8343-Jul-06 11:20
emran8343-Jul-06 11:20 
Questionproblem with asp.net 2.0 TreeView Pin
WebMaster3-Jul-06 11:06
WebMaster3-Jul-06 11:06 
AnswerRe: problem with asp.net 2.0 TreeView Pin
minhpc_bk3-Jul-06 19:57
minhpc_bk3-Jul-06 19:57 
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 

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.