Opening a word document on IIShttp://forums.asp.net/t/1773723.aspx/1?Opening+a+word+document+on+IISTue, 28 Feb 2012 12:44:44 -050017737234850544http://forums.asp.net/p/1773723/4850544.aspx/1?Opening+a+word+document+on+IISOpening a word document on IIS <p>Hello All,</p> <p></p> <p>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.</p> <p></p> <p>using Aspose.Words;<br> <br> public partial class Default5 : System.Web.UI.Page<br> {<br> &nbsp;&nbsp;&nbsp; protected void Page_Load(object sender, EventArgs e)<br> &nbsp;&nbsp;&nbsp; {<br> <br> &nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp; protected void Button1_Click(object sender, EventArgs e)<br> &nbsp;&nbsp;&nbsp; {<br> &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Document doc = new Document();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DocumentBuilder builder = new DocumentBuilder(doc);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doc.Save(@&quot;C:\inetpub\wwwroot\List\Data\&quot; &#43; TextBox1.Text &#43; &quot;.docx&quot; );<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string paths = @&quot;C:\inetpub\wwwroot\List\Data\&quot; &#43; TextBox1.Text &#43; &quot;.docx&quot; ;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Process prc = new Process();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prc.StartInfo.FileName = paths;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; prc.Start();<br> }</p> <p>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?</p> <p></p> <p></p> 2012-02-25T11:36:50-05:004850663http://forums.asp.net/p/1773723/4850663.aspx/1?Re+Opening+a+word+document+on+IISRe: Opening a word document on IIS <p>Hi</p> <pre class="default prettyprint"><span face="monospace" style="font-family:monospace"><span>string paths = @&quot;C:\inetpub\wwwroot\List\Data\&quot; &#43; TextBox1.Text &#43; &quot;.docx&quot; ;</span></span></pre> <pre class="default prettyprint"><span face="monospace" style="font-family:monospace"><span></span></span></pre> <p>his is not a valid filepath.</p> <pre class="default prettyprint"><span face="monospace" style="font-family:monospace"><span></span></span></pre> <p>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:</p> <pre class="default prettyprint"><pre class="prettyprint">string filePath = Server.MapthPath(&quot;~/WordDocs/stopwords.doc&quot;);</pre></pre> <pre class="default prettyprint"><pre class="prettyprint"><span class="pun">Thnaks...</span></pre></pre> <pre class="default prettyprint"><span face="monospace" style="font-family: monospace;"><span><br /></span></span></pre></pre> 2012-02-25T14:09:46-05:004850782http://forums.asp.net/p/1773723/4850782.aspx/1?Re+Opening+a+word+document+on+IISRe: Opening a word document on IIS <p>Hi abiruban,</p> <p></p> <p>My folder where i store my File in my application itself. I have stored my application in inetpub in C folder.</p> <p></p> <p>Smitha</p> <p></p> <p></p> <p></p> 2012-02-25T16:58:21-05:004851799http://forums.asp.net/p/1773723/4851799.aspx/1?Re+Opening+a+word+document+on+IISRe: Opening a word document on IIS <p>Hi,</p> <p>It because the permission reason.</p> <p>If you use the window7, the IIS work under the IIS_IUsers account.</p> <p>If you use the window2004, it works in the network account.</p> <p>You should give there accounts enough permission, thus you are able to store the files into the folders.</p> 2012-02-27T02:26:56-05:004854708http://forums.asp.net/p/1773723/4854708.aspx/1?Re+Opening+a+word+document+on+IISRe: Opening a word document on IIS <p>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?</p> 2012-02-28T11:05:00-05:004854899http://forums.asp.net/p/1773723/4854899.aspx/1?Re+Opening+a+word+document+on+IISRe: Opening a word document on IIS <p>Hi!</p> <p>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?</p> <p>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 <a href="http://www.docentric.com">Docentric</a> toolkit. You can create templates right in MS Word and then process and populate them with data to generate .docx documents.</p> <p></p> 2012-02-28T12:44:44-05:00