I have a web application in which i can create word, excel and ppt files and store. Everything works on visual studio 2008. When I deploy this on IIS, nothing works. Then I searched that Microsoft does not support server side automation. Then I was looking
for third party API's. then found Aspose.Words for creating word documents. My code is given below.
using Aspose.Words;
public partial class Default5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try to put the file inside the web application folder, for example create a folder called WordDocs inside the place where you deployed your ASP.NET application then get the file path like this:
I found out one new thing. While searching how to solve this, I found one more API officewriter. I downloded and tried working on it and it worked fine including on the server. It comes as if we are downloding an attachment. Then I found that Prc.Start()
will not work on server. It only works on client. I tried opening different types of files like .jpg and all, but prc.start() will not open any file on server. Is there any alternative way to open a file on server?
I don't see a valid scenario for spawning new processes on the server from a web application. Why would you like to do it? Just for testing purposes? What is the error you receive?
If you would like to generate Word documents (populated by data from a database) on the server and need a robust solution, I would strongly suggest you to check out the
Docentric toolkit. You can create templates right in MS Word and then process and populate them with data to generate .docx documents.
slm3003
Member
133 Points
166 Posts
Opening a word document on IIS
Feb 25, 2012 11:36 AM|LINK
Hello All,
I have a web application in which i can create word, excel and ppt files and store. Everything works on visual studio 2008. When I deploy this on IIS, nothing works. Then I searched that Microsoft does not support server side automation. Then I was looking for third party API's. then found Aspose.Words for creating word documents. My code is given below.
using Aspose.Words;
public partial class Default5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
doc.Save(@"C:\inetpub\wwwroot\List\Data\" + TextBox1.Text + ".docx" );
string paths = @"C:\inetpub\wwwroot\List\Data\" + TextBox1.Text + ".docx" ;
Process prc = new Process();
prc.StartInfo.FileName = paths;
prc.Start();
}
This code also works on VS 2008 but not on IIS. It is creating the file in IIS but not opening the file. What is the mistake I have done?
abiruban
All-Star
16038 Points
2734 Posts
Re: Opening a word document on IIS
Feb 25, 2012 02:09 PM|LINK
Hi
string paths = @"C:\inetpub\wwwroot\List\Data\" + TextBox1.Text + ".docx" ;his is not a valid filepath.
try to put the file inside the web application folder, for example create a folder called WordDocs inside the place where you deployed your ASP.NET application then get the file path like this:
***DON'T FORGET TO CLICK “MARK AS ANSWER” ON THE POST IF HELPED YOU.
slm3003
Member
133 Points
166 Posts
Re: Opening a word document on IIS
Feb 25, 2012 04:58 PM|LINK
Hi abiruban,
My folder where i store my File in my application itself. I have stored my application in inetpub in C folder.
Smitha
Hua-Jun Li -...
All-Star
75950 Points
5608 Posts
Re: Opening a word document on IIS
Feb 27, 2012 02:26 AM|LINK
Hi,
It because the permission reason.
If you use the window7, the IIS work under the IIS_IUsers account.
If you use the window2004, it works in the network account.
You should give there accounts enough permission, thus you are able to store the files into the folders.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
slm3003
Member
133 Points
166 Posts
Re: Opening a word document on IIS
Feb 28, 2012 11:05 AM|LINK
I found out one new thing. While searching how to solve this, I found one more API officewriter. I downloded and tried working on it and it worked fine including on the server. It comes as if we are downloding an attachment. Then I found that Prc.Start() will not work on server. It only works on client. I tried opening different types of files like .jpg and all, but prc.start() will not open any file on server. Is there any alternative way to open a file on server?
Jure.Les
Member
376 Points
69 Posts
Re: Opening a word document on IIS
Feb 28, 2012 12:44 PM|LINK
Hi!
I don't see a valid scenario for spawning new processes on the server from a web application. Why would you like to do it? Just for testing purposes? What is the error you receive?
If you would like to generate Word documents (populated by data from a database) on the server and need a robust solution, I would strongly suggest you to check out the Docentric toolkit. You can create templates right in MS Word and then process and populate them with data to generate .docx documents.