Click here to Skip to main content
15,910,083 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionASP.NET 2.0 Hosting Pin
nidhins1-Jul-06 15:10
nidhins1-Jul-06 15:10 
AnswerRe: ASP.NET 2.0 Hosting Pin
Hy Chanhan2-Jul-06 3:51
professionalHy Chanhan2-Jul-06 3:51 
QuestionNot getting output while using AJAX Pin
ravindradonkada1-Jul-06 7:36
ravindradonkada1-Jul-06 7:36 
AnswerRe: Not getting output while using AJAX Pin
_mubashir2-Jul-06 8:41
_mubashir2-Jul-06 8:41 
GeneralRe: Not getting output while using AJAX Pin
Tiger4565-Jul-06 2:42
Tiger4565-Jul-06 2:42 
QuestionBind datagrid with ilist Pin
chnikhil1-Jul-06 1:23
chnikhil1-Jul-06 1:23 
QuestionProtect my pdf documents Pin
Tech4U1-Jul-06 0:14
Tech4U1-Jul-06 0:14 
AnswerRe: Protect my pdf documents [modified] Pin
Jesse Squire2-Jul-06 3:07
Jesse Squire2-Jul-06 3:07 
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

  {

    /// <summary>

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

    ///  accross requests.

    /// </summary>

    ///

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

    ///

    public bool IsReusable

    {

      get

      {

        return true;

      }

    } // End property IsReusable

 

 

    /// <summary>

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

    /// </summary>

    ///

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

    ///

    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. Smile | :)

--Jesse
GeneralRe: Protect my pdf documents Pin
minhpc_bk2-Jul-06 15:40
minhpc_bk2-Jul-06 15:40 
GeneralRe: Protect my pdf documents Pin
Jesse Squire3-Jul-06 3:08
Jesse Squire3-Jul-06 3:08 
GeneralRe: Protect my pdf documents Pin
minhpc_bk3-Jul-06 19:55
minhpc_bk3-Jul-06 19:55 
GeneralRe: Protect my pdf documents Pin
Tech4U2-Jul-06 18:58
Tech4U2-Jul-06 18:58 
GeneralRe: Protect my pdf documents Pin
Jesse Squire3-Jul-06 2:53
Jesse Squire3-Jul-06 2:53 
GeneralRe: Protect my pdf documents Pin
harinath20-Jul-06 0:17
professionalharinath20-Jul-06 0:17 
GeneralRe: Protect my pdf documents Pin
Jesse Squire21-Jul-06 2:34
Jesse Squire21-Jul-06 2:34 
GeneralRe: Protect my pdf documents Pin
harinath23-Jul-06 19:29
professionalharinath23-Jul-06 19:29 
Questionmouseover event on datalist. Pin
Amit Agarrwal30-Jun-06 23:53
Amit Agarrwal30-Jun-06 23:53 
Questionserver error when hosted on INTERNET Pin
nishak30-Jun-06 20:42
nishak30-Jun-06 20:42 
QuestionAccessing Web Control in JavaScript Pin
venkatasivaramaprasad30-Jun-06 20:34
venkatasivaramaprasad30-Jun-06 20:34 
AnswerRe: Accessing Web Control in JavaScript Pin
Uma Kameswari1-Jul-06 1:32
Uma Kameswari1-Jul-06 1:32 
GeneralRe: Accessing Web Control in JavaScript Pin
venkatasivaramaprasad2-Jul-06 18:55
venkatasivaramaprasad2-Jul-06 18:55 
AnswerRe: Accessing Web Control in JavaScript Pin
Guffa1-Jul-06 3:51
Guffa1-Jul-06 3:51 
AnswerRe: Accessing Web Control in JavaScript Pin
RichardGrimmer4-Jul-06 3:04
RichardGrimmer4-Jul-06 3:04 
Questionsearch query not working Pin
Amit Agarrwal30-Jun-06 20:24
Amit Agarrwal30-Jun-06 20:24 
AnswerRe: search query not working Pin
venkatasivaramaprasad30-Jun-06 21:14
venkatasivaramaprasad30-Jun-06 21:14 

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.