0

I have an ASP.NET/C# web form for making personnel action requests for the IT department to act on. It outputs via email, formatted as HTML to increase readability. However, I'd like to expand this to include general HR information because much of it is redundant with what the requester would already be sending to HR anyway, resulting in duplicate information. Given the presence of information like SSNs, though, I'd really rather not email this information, partly because our system flags that kind of content.

Given this, is it possible to somehow send the form data as a file (in whatever format— I'd imagine PDF— and preferably more reader-friendly than plain text) output to a network folder, ideally along with sending the non-sensitive information in am email to then be forwarded to us? I know you can access network folders in ASP.NET (not that I've done it, mind you), but I don't know if you can dump form output to a file the way I'd like to do it.

1 Answer 1

1

The short answer is yes, as long as you have your ASP.NET Web application running with an account (the application pool identity) with sufficient permissions to write to the network share you want to save the file to, you can do this.

A common method is to set up a distinct application pool just for your one web application, and to configure it to use a domain account that is provisioned exclusively for this use. (Some people call them faceless account or system accounts.) Make sure to grant write permissions to the network share where you want to save the files.

Then, use regular System.IO .NET classes to save the files to the network share. There are countless examples of this, so you should easily find one close to what you need.

2
  • How would that play with something like this code.msdn.microsoft.com/Convert-from-HTML-to-PDF-09ce2a1d or this pdfsharp.com/PDFsharp/… ? I'd really like to take the HTML-style output I'm already generating and PDF it for reader-friendliness. Dec 14, 2015 at 23:28
  • That's really a whole other (new) question. The "HTML-to-PDF-Conversion" library expects that you already have the HTML available (perhaps as a result of a web request), not that you are currently generating the HTML in order to respond to a web request. PDFSharp expects you to use its methods to generate the PDF; it doesn't convert from HTML. Either way, at some point, you'll find something like a ".Save(filename)" method hanging from a top-level object (PdfDocument, etc.), where you will just target your network share.
    – Alan McBee
    Dec 15, 2015 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.