Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 14th, 2006, 08:50 AM
Authorized User
 
Join Date: Jan 2006
Location: Pune, Maharashtra, India.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create word file in asp.net,c#

Hi friends,
   I want to create a word file in asp.net in c#.But it is giving me error like asp.net dont't have valid access for the requested resource.plz tell me how to do it??

  #2 (permalink)  
Old February 14th, 2006, 02:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

How are you trying to create the word file?

Brian
  #3 (permalink)  
Old February 15th, 2006, 02:51 AM
Authorized User
 
Join Date: Jan 2006
Location: Pune, Maharashtra, India.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have add reference to Micosoft.word dll in my project.This is the code:


Object missing=System.Reflection.Missing.Value;
    Object filename="D:\\DocFiles\\myfile.doc";
    object readOnly = false;
    object isVisible = true;

    Word.ApplicationClass oWordApp= new ApplicationClass();
    Word.Document oWordDoc=oWordApp.Documents.Add(ref missing,ref missing, ref missing,ref missing);
    oWordDoc.Activate();
    oWordApp.Selection.TypeText("This is the text");
    oWordApp.Selection.TypeParagraph();
    oWordDoc.SaveAs(ref filename,ref missing,ref missing,ref missing,
        ref missing,ref missing,ref missing,ref missing,ref missing,
        ref missing,ref missing,
    ref missing,ref missing,ref missing,ref missing,ref missing);

    oWordApp.Application.Quit(ref missing,ref missing, ref missing);



but it is giving me error:

Access is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

Source Error:

Line 50: object isVisible = true;
Line 51: object missing = System.Reflection.Missing.Value;
Line 52: Word.ApplicationClass oWordApp = new Word.ApplicationClass();
Line 53:


please tell me what is the solution.Should It requires some IIS settings?



  #4 (permalink)  
Old February 15th, 2006, 04:34 AM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Isn't the solution in the very verbose error message you're getting? It almost explains step by step what to do.....

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #5 (permalink)  
Old February 15th, 2006, 07:05 AM
Authorized User
 
Join Date: Jan 2006
Location: Pune, Maharashtra, India.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried for the steps given in the error but still it is not working

  #6 (permalink)  
Old February 15th, 2006, 09:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Add the ASPNET account write access to the folder you are trying to write to. That is what Imar was talking about.

Brian
  #7 (permalink)  
Old February 17th, 2006, 06:28 AM
Authorized User
 
Join Date: Jan 2006
Location: Pune, Maharashtra, India.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have added aspnet user and given the access right for read write ,then also it is not working

  #8 (permalink)  
Old February 17th, 2006, 09:07 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Imar, could this be a dcomcnfg setup problem?

Brian
  #9 (permalink)  
Old February 17th, 2006, 02:50 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yeah, that's quite possible. I never tried to create Word files on the server in ASP.NET, but that might indeed be necessary to make it work.

Mohini: check out this thread: http://p2p.wrox.com/topic.asp?TOPIC_ID=14057

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #10 (permalink)  
Old March 2nd, 2006, 10:06 AM
Authorized User
 
Join Date: Mar 2006
Location: Pune, Maharashatra, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 This is the common error while providing an access to any file.
Error itself contains the answer of the problem.
Please do <identity impersonate="true"> in web.config
check if it is working fine otherwise create one local user and set the identity impersonate = true for it.

It should work fine.

Thanks,
Manish Sharma


 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
to create PDF from word file sunilbedre Excel VBA 0 November 29th, 2007 06:39 AM
How to create MS Word like Callout in .NET ashu_from_india Visual Studio 2005 0 July 12th, 2007 06:48 AM
Access denied, can't create xml file from ASP.NET goldablasha C# 3 February 27th, 2007 05:50 AM
Reading word file in asp.net 1.1 anujrathi ASP.NET 1.0 and 1.1 Professional 0 August 4th, 2006 01:09 AM
Can I create my own File Field control in ASP.Net vbmazza ASP.NET 1.0 and 1.1 Professional 1 February 22nd, 2006 11:45 AM



All times are GMT -4. The time now is 12:48 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.