Save PDF on web server-operation not allowed

Hi all

Problem Summary

I've created "PDF" directory to store all PDF create, and give write permission on that folder including subfolders and file

Using code below


PDFCreatorPilot3Lib.PDFDocument3Class PDF = new PDFCreatorPilot3Lib.PDFDocument3Class();


// initialize PDF Engine
PDF.StartEngine("demo@demo", "demo");

// set filename

//PDF.FileName = "PDF" + FirstName + ".PDF";
PDF.FileName = Server.MapPath("/PDF/" + FirstName + ".PDF");
PDF.AutoLaunch = true; // auto-open generated pdf document

// start document generation

PDF.BeginDoc();

// draw "HELLO, PDF" message on the current PDF page

// Header
PDF.PDFPAGE_SetActiveFont("Verdana", true, false, false, false, 14, 0);
PDF.PDFPAGE_TextOut(10, 20, 0, "Access Direct Learning");

// Content of PDF
PDF.PDFPAGE_SetActiveFont("Calibri", true, false, false, false, 12, 0);
PDF.PDFPAGE_TextOut(10, 40, 0, "First Name :" + FirstName);

// finalize document generation

PDF.EndDoc();

Error

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: System.Security.Permissions.SecurityPermission

Source Error:

Line 191:
Line 192: PDF.EndDoc();
Line 193: }
Line 194:}

Any suggestion or advice please

Thanks
ayazhodaAsked:
Who is Participating?
 
Bob LearnedCommented:
Where did you put it in the web.config file?

location Element (ASP.NET Settings Schema)  
http://msdn2.microsoft.com/en-us/library/b6x6shw7.aspx

Example:

<configuration>
   <location path="UploadPage.aspx">
      <httpRuntime maxRequestLength="128"/>
   </location>
</configuration>

Bob
0
 
RedKelvinCommented:
Hi, it still sounds like a security violation, for that user.

The code is running on the server so it should be using the IUSR account to attempt the write. Check the perms for IUSR
0
 
ayazhodaAuthor Commented:
Hi

I've given all permission to IUSR  but still got same.

here's trace track which might help

Stack Trace:

[SecurityException: System.Security.Permissions.SecurityPermission]
   Test2.generate_PDF() in e:\kunden\homepages\30\d205089371\Test2.aspx.cs:193
   Test2.btn_SubmitOnlineForm_Click(Object sender, EventArgs e) in e:\kunden\homepages\30\d205089371\Test2.aspx.cs:146
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6953
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +154
   System.Web.UI.Page.ProcessRequest() +86
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.test2_aspx.ProcessRequest(HttpContext context) in App_Web_dkwgpfur.0.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Bob LearnedCommented:
With .NET framework version are you working with (2.0 or 1.1)?

Bob
0
 
ayazhodaAuthor Commented:
Hi bob

I am doing all this development on my laptop which has .NET framework 2.0 and web server where site is running do support .NET framework 1.1

Do have message some time like this method is absolute but i have stick with it b/c webserver support .Net 1.1

Any idea where problem exists

Thanks
0
 
Bob LearnedCommented:
Does the web site support anonymous access, and are you using Windows Authentication?

Bob
0
 
ayazhodaAuthor Commented:
Hi Bob

does not support anonymous access

Thanks
0
 
Bob LearnedCommented:
If you aren't using anonymous access and Windows Authentication, then I don't think that the user is going to be IUSR_<machine>, it is going to be the Windows identity that is authenticated.

Bob
0
 
ayazhodaAuthor Commented:
I think it windows authentication but i am still on same point
0
 
ayazhodaAuthor Commented:
In Addition I've checked with my service provider they told me to create Application folder in order to save those PDF, which i did but it didnt work as well.

Other thing i found out on internet is some thing to do with web config security setting

http://msdn2.microsoft.com/en-us/library/87x8e4d1(vs.80).aspx
0
 
Bob LearnedCommented:
You can configure security access through a web.config file, with a <location> element and the correct settings.  Did you find a solution with the web.config settings?

Bob
0
 
ayazhodaAuthor Commented:
hi Bob

I am trying to edit web config file but it cant recognise <location> tag

no idea why

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.