?
Solved

Save PDF on web server-operation not allowed

Posted on 2007-10-21
12
Medium Priority
?
670 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:ayazhoda
  • 6
  • 5
12 Comments
 
LVL 22

Expert Comment

by:RedKelvin
ID: 20119677
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
 

Author Comment

by:ayazhoda
ID: 20126393
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20139501
With .NET framework version are you working with (2.0 or 1.1)?

Bob
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 

Author Comment

by:ayazhoda
ID: 20143629
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20144033
Does the web site support anonymous access, and are you using Windows Authentication?

Bob
0
 

Author Comment

by:ayazhoda
ID: 20154581
Hi Bob

does not support anonymous access

Thanks
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20154714
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
 

Author Comment

by:ayazhoda
ID: 20162574
I think it windows authentication but i am still on same point
0
 

Author Comment

by:ayazhoda
ID: 20163164
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20163212
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
 

Author Comment

by:ayazhoda
ID: 20170994
hi Bob

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

no idea why

Thanks
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 20171026
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

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Loops Section Overview
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question