applying irm permission in asp .net

  • Thread starter Thread starter Raan
  • Start date Start date
R

Raan

Hi,
I can open, edit,save the file,but I can not apply IRM to Word in
asp.net.

my code likes this:


Doc = WordApplication.Documents.Open(); // open
WordApplication.Selection.TypeText("edit it");// edit it
// Doc.Permission.Add(userid, permission, expireddate) // apply IRM
Doc.Save(); // save
WordApplication.Application.quit();// quit


if i uncomments the Permission.Add code, it will throws exception
message


Word cannot save or create this file. Make sure that the disk you want
to
save the file on is not full, write-protected, or damaged.
(C:\test\test.doc)


The code works fine in Windows App,but fails in asp.net.


I have full-control access to the doc, as I have do the configuration
according to http://support.microsoft.com/kb/288366/
And my web application runs under the admin account.


Can anyone give me some clues? Thanks!

Raan
 
Doc = WordApplication.Documents.Open(); // open

Server-side Office automation isn't supported by Microsoft because it
doesn't work:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2
I have full-control access to the doc, as I have do the configuration
according to http://support.microsoft.com/kb/288366/
And my web application runs under the admin account.

That's, possibly, the worst thing you can do in terms of (lack of)
robustness. I suggest you read that article again, noting specifically:

"We do not recommend or support Automation to a Microsoft Office application
from an unattended user account."

"Caution Automation of any Office application from an unattended,
non-interactive user account is risky and unstable. A single error in code
or configuration can result in a dialog box that can cause the client
process to stop responding (hang), that can corrupt data, or that can even
crash the calling process (which can bring down your Web server if the
client is ASP)."

"Warning Office was not designed, and is not safe, for unattended execution
on a server. Developers who use Office in this manner do so at their own
risk."

Use this instead: http://www.aspose.com/Products/Aspose.Words/Default.aspx
 
Back
Top